Answered step by step
Verified Expert Solution
Link Copied!

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 0
A Constructor that accepts a Rectangle and a double
A constructor that accepts three doubles
Getters/setters (also getters/setters 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.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

identify current issues relating to equal pay in organisations

Answered: 1 week ago