C++ Project: Cube Class
A Cube Class
The Rectangle class has 2 dimensions: length and width. The length and width are private so that we can guarantee that the dimensions are always positive.
Using the Rectangle class as a model, create a Cube class that has 3 dimensions: length, width and height.
Note: This is actually a cuboid, a cube has all dimensions the same.
- Private double length, width, and height;
- All public getter and setter functions for the 3 dimensions;
- Safeguard that all dimensions are greater than 0.
- a default constructor with no arguments;
- a constructor that accepts all 3 values;
- a toString method that will return the cube as a string. Example: 1X2X3
- a volume method that returns the volume of the cube. Example 1X2X3 has a volume of 6
- Overload ==, <, <=, >, >= operators (use the volume to compare);
Submit one Word document (in Blackboard under Assignments) with all of the following as part of this assignment:
- Instead of a flowchart, you are to include a UML representation of the class as shown in the text.
- The class definition and main in one cpp file (similar to the one for the Rectangle example.)
- Sample output showing several different outputs and an example where the user tried to assign 0 a dimension
- Your output should show all of the methods listed above.
This web site, and all pages therein, are the sole property and responsibility of Zebra0.com.
It is not endorsed, sponsored, or provided by or on behalf of Montgomery College.