Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started