Question: II . Design a class Cube, that has the following properties: A base as a Rectangle object and a height. So your class has two
II Design a class Cube, that has the following properties:
A base as a Rectangle object and a height. So your class has two private members: Rectangle base and double height.
A default constructor tht sets the base to default Rectangle and height to
A Constructor that accepts a Rectangle and a double
A constructor that accepts three doubles
Getterssetters also getterssetters for length and width
Method Area that computes the areas of all surfaces of the cube; use any already defines method previously in Rectangle class.
Method Volume that computes the volume, use any already defines method previously in Rectangle class.
Method add that accepts a Cube and returns the sum of this and the input Cube, without changing this object
toString that returns the object as a string
equals that accepts a Cube and returns true if the two are the same. Use previously defined methods in this class or in the Rectangle class whenever possible.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
