Currently my mission in life is to write a box class which consists of:
So my point class is already done and works:Quote:
Write a C++ class called Box. You should create the following 3 seperate files:
* Box.h: the header file for the box class
* Box.cpp: the code and data for the box class; and
* boxtdrivr.cpp
Reuse the C++ class you wrote for the previous assingment.
* Point.h: the header file for the point class
* Point.cpp: the code and data for the point class; and
the point class will consist of the following memeber function:
* constructor with arguments for the three points to define the box;
* constructor with arguments for hidth, width and depth(assume that one , point is the orgin)
* a function to compute the surface area of the box;
* a function to compute the volume of the box;
* seperate accessor fubctions for getting each attribute;
* seperate functions that will return the deminsions of the box (H,W,D)
* a function that will return the largest deminsion of the box
* a function that will return the smallest deminsion of the box
* separate accessor functions for getting each attribute.
Point.h
Point.cpp:Code:/**************************************************************************
* class: XYZPoint
*
* Description:
* A constructor that passes 3 variables
* A default constructor that has preset values
* A function for setting the x,y and z variables
* A function to compute the distance between the two points
* A function to compute the midpoint between the two points
* A function that will display all the points attributes
* Sperate accessor functions fro getting each attribute.
*
***************************************************************************/
class XYZPoint
{
//constructor that passes 3 veriables
private: //declares Coorodinates
double xCoor;
double yCoor;
double zCoor;
public:
/**************************************************************************
* Discription:
* Default Constructor that sets the x,y & z Coor to 0.00 if no value
* is passed.
***************************************************************************/
XYZPoint()
{
xCoor = 0.000;
yCoor = 0.000;
zCoor = 0.000;
}
/**************************************************************************
* Discription:
* Prototype Constructor that passes three doubles, defines the points
* of the triangle
***************************************************************************/
XYZPoint(double, double, double);
/**************************************************************************
* Discription:
* Prototype get*Coor that passes an X,Y, or Z Coordinate
***************************************************************************/
double getXCoor();
double getYCoor();
double getZCoor();
/**************************************************************************
* Discription:
* Prototype set*Coor that passes an X,Y, or Z Coordinate
***************************************************************************/
void setXCoor(double);
void setYCoor(double);
void setZCoor(double);
/**************************************************************************
* Discription:
* calculates the distance between coordinates of XYZPoint
***************************************************************************/
double distance(XYZPoint);
/**************************************************************************
* Discription:
* calculates the midpoint between coordinates of XYZPoint
***************************************************************************/
void midPoint(XYZPoint, XYZPoint);
/**************************************************************************
* Discription:
* Allows user to output to anywhere or anything
***************************************************************************/
void display(ostream &);
};
Now im trying to buile my Box class and having problems:Code://prototype Constructor passing two doubles
XYZPoint::XYZPoint(double x, double y, double z)
{
xCoor = x;
yCoor = y;
zCoor = z;
}
/**************************************************************************
* class XYZ Accessors
***************************************************************************/
double XYZPoint::getXCoor()
{
return xCoor;
}
double XYZPoint::getYCoor()
{
return yCoor;
}
double XYZPoint::getZCoor()
{
return zCoor;
}
/**************************************************************************
* class XYZ Modifiers
***************************************************************************/
void XYZPoint::setXCoor(double x)
{
xCoor = x;
}
void XYZPoint::setYCoor(double y)
{
yCoor = y;
}
void XYZPoint::setZCoor(double z)
{
zCoor = z;
}
/**************************************************************************
* calculates the difference in between the xCoor with
***************************************************************************/
double XYZPoint::distance(XYZPoint p1)
{
double xDiff = xCoor - p1.getXCoor();
double yDiff = yCoor - p1.getYCoor();
double zDiff = zCoor - p1.getZCoor();
double result = sqrt(xDiff*xDiff + yDiff*yDiff + zDiff*zDiff);
return result;
}
/**************************************************************************
* Function Description: finds the midpoint of the X,Y & Z Corrodinates
***************************************************************************/
void XYZPoint::midPoint(XYZPoint p2, XYZPoint p3)
{
xCoor = (p2.getXCoor() + p3.getXCoor())/2.0;
yCoor = (p2.getYCoor() + p3.getYCoor())/2.0;
zCoor = (p2.getZCoor() + p3.getZCoor())/2.0;
}
/**************************************************************************
* Funciont Description: displays
***************************************************************************/
void XYZPoint::display(ostream& out) //pN.display(cout)
{
out << fixed << setprecision(3) << "(" << xCoor << ","
<< yCoor << "," << zCoor <<")";
}
Box.h:
Box.cpp:Code:#ifndef BOX_H
#define BOX_H
#include "Point.h"
/**************************************************************************
* Author: Glen Newell
* Class: XYZBox
*
* Description:
* A constructor for 3 points that define the box *
* A constructor with arguments for hight, width and depth *
* A function to compute the surface area of the box
* A function to compute the volume
* Sperate accessor functions fro getting each attribute.
* Separate functions that will return the demensions of the box
* A function that will return the largest dimension of the box
* A function that will return the smallest dimension of the box
*
***************************************************************************/
class XYZBox
{
//constructor that defines the 3 points of the box
private: //declares Coorodinates
XYZPoint xCoor;
XYZPoint yCoor;
XYZPoint zCoor;
public:
/**************************************************************************
* Class: XYZBox
* Function: XYZBox
*
* Discription:
* Prototype Constructor that passes three doubles, defines Box(H,W,D)
***************************************************************************/
XYZBox(double, double, double);
XYZBox(XYZPoint, XYZPoint, XYZPoint);
/**************************************************************************
* Function: get(X,Y,Z)Coor
*
* Discription:
* Prototype get*Coor that passes an X,Y, or Z Coordinate
***************************************************************************/
double getXCoor(double);
double getYCoor(double);
double getZCoor(double);
/**************************************************************************
* Function: set(X,Y,Z)Coor
*
* Discription:
* Prototype set*Coor that passes an X,Y, or Z Coordinate
***************************************************************************/
void setXCoor(double);
void setYCoor(double);
void setZCoor(double);
/**************************************************************************
* Function: surfaceArea
*
* Discription:
* calculates the difference in between the xCoor with
***************************************************************************/
double surfaceArea();
/**************************************************************************
* Function: Volume
*
* Discription:
* calculates the volume of the box
***************************************************************************/
double volume(); // not sure if it shouls be this
// void volume(XYZBox); // or this
/**************************************************************************
* Function: largeDimension
*
* Discription:
* calculates the Largest Dimension of the box
***************************************************************************/
void largeDimension (XYZBox, XYZBox);
/**************************************************************************
* Function: smallDimension
*
* Discription:
* calculates the Smallest Dimension of the box
***************************************************************************/
void smallDimension (XYZBox, XYZBox);
};
#endif
Right now im getting errors with the get_Coor Functions, the set_Coor and the volumeCode:#include "Box.h"
XYZBox::XYZBox (XYZPoint p1, XYZPoint p2, XYZPoint p3)
{
xCoor = p1;
yCoor = p2;
zCoor = p3;
}
XYZBox::XYZBox (double x, double y, double z)
{
xCoor.setXCoor(0);
xCoor.setYCoor(0);
xCoor.setZCoor(0);
yCoor.setXCoor(0);
yCoor.setYCoor(0);
yCoor.setZCoor(0);
zCoor.setXCoor(0);
zCoor.setYCoor(0);
zCoor.setZCoor(0);
}
/**************************************************************************
* Function: get(X,Y,Z)Coor
*
* Discription:
* Prototype get*Coor that passes an X,Y, or Z Coordinate
*
***************************************************************************/
double XYZBox::getXCoor() //depth
{
return xCoor;
}
double XYZBox::getYCoor() //width
{
return yCoor;
}
double XYZBox::getZCoor() //height
{
return zCoor;
}
/**************************************************************************
* Function: set(X,Y,Z)Coor
*
* Discription:
* Prototype set*Coor that passes an X,Y, or Z Coordinate
*
***************************************************************************/
void XYZBox::setXCoor()
{
return xCoor;
}
void XYZBox::setYCoor()
{
return yCoor;
}
void XYZBox::setZCoor()
{
return zCoor;
}
/**************************************************************************
* Function: distance
*
* Discription:
* Calculates the difference in between the xCoor with
*
***************************************************************************/
double XYZBox::surfaceArea()
{
double depth = abs(xCoor.getXCoor() - yCoor.getXCoor());
double width = abs(yCoor.getYCoor() - zCoor.getYCoor());
double height = abs(zCoor.getZCoor() - xCoor.getZCoor());
double result = abs((2*(depth*width))+(2*(depth*height))+(2*(width*height)));
return result;
}
/**************************************************************************
* Function: volume
*
* Discription:
* Calculates the volume of the Box.
*
***************************************************************************/
/* void XYZBox::volume(XYZBox p1) // the other way i think might work?
{
double volume = p1.getXCoor()*p1.getYCoor()*p1.getZCoor();
return volume;
}
*/
double XYZBox::volume()
{
double volume = xCoor.getXCoor()*
yCoor.getYCoor()*zCoor.getZCoor();
return volume;
}
/**************************************************************************
* Function: largeDimension
*
* Discription:
* calculates the Largest Dimension of the box
***************************************************************************/
void largeDimension (XYZBox p1, XYZBox p2);
{
// dont know what to put here?
}
/**************************************************************************
* Function: smallDimension
*
* Discription:
* calculates the Smallest Dimension of the box
***************************************************************************/
void smallDimension (XYZBox p1, XYZBox p2);
{
}
simalar to:
C:\...Box.cpp(51) : error C2511: 'getXCoor' : overloaded member function 'double (void)' not found in 'XYZBox'
any suggestions? examples are a plus.