// Justin C. Miller
// University of Wisconsin Oshkosh
// Made for: http://www.geocities.com/neonprimetime.geo/index.html
// Date: 2001
// Borland Builder 4.0
#include
#include
class Box
{
private:
double length ;
double width ;
double height ;
public:
Box() ; // 1st constructor
Box(double, double, double) ; // 2nd constructor
double volume() ;
void printDimensions() ;
void setLength(double) ;
void setWidth(double) ;
void setHeight(double) ;
double getLength() ;
double getWidth() ;
double getHeight() ;
} ;
Box::Box()
{length = 0 ; width = 0 ; height = 0 ;}
Box::Box(double l, double w, double h)
{length = l ; width = w ; height = h ;}
double Box::getHeight()
{return height ;}
double Box::getWidth()
{return width ;}
double Box::getLength()
{return length ;}
void Box::setHeight(double h)
{height = h;}
void Box::setWidth(double w)
{width = w ;}
void Box::setLength(double l)
{length = l;}
double Box::volume()
{return length * width * height ;}
void Box::printDimensions()
{
cout << "Length = " << length << endl ;
cout << "Height = " << height << endl ;
cout << "Width = " << width << endl ;
}
int main()
{
Box a ; // uses the 1st constructor
Box b(2, 4, 6) ; // uses the 2nd constructor
cout << "After Box a & Box b(2,4,6) ...." << endl ;
cout << "Box a dimension..." << endl ;
a.printDimensions() ;
cout << "Box b dimension..." << endl ;
b.printDimensions() ;
system("pause") ;
system("cls") ;
a.setLength(7) ;
a.setHeight(3) ;
a.setWidth(9) ;
cout << "a Dimensions after 3 set's..." << endl ;
cout << "L=" << a.getLength() << endl ;
cout << "W=" << a.getWidth() << endl ;
cout << "H=" << a.getHeight() << endl ;
system("pause") ;
system("cls") ;
cout << "volume of box a = " << a.volume() << endl ;
cout << "volume of box b = " << b.volume() << endl ;
return 0 ;
}
               (
geocities.com/neonprimetime.geo/cpp)                   (
geocities.com/neonprimetime.geo)