Question: IN JAVA Most of these are self-explanatory, with the exception of the default constructor and toString() method. The default constructor should initialize the values of

 IN JAVA Most of these are self-explanatory, with the exception of

IN JAVA Most of these are self-explanatory, with the exception of the default constructor and toString() method. The default constructor should initialize the values of the instance fields so the color is "Red" and all of the dimensions of the cube are 14. The toString() method should return a string that is the concatenation of all of the instance fields.

To test your new class, you will need to implement a driver class. This class should be named CubeDriver and should only contain a public static void main method. Within this method, do the following tests to ensure that your class works correctly

1. Create a default cube and call it cube1.

2. Create a second cube with dimensions (w=30, h=10, d=40) and make its color "Orange". Call it cube2.

3. Create a third cube with dimensions (w=10, h=40, d=20) and make its color "Blue". Call it cube3

4. Change the color of cube2 to "Black"

5. Change the width of cube1 to 37.

6. Display the surface area of each cube and label the output with the cube color

7. Display the volume of each cube and label the output with the cube color.

8. Display the total volume of all of the cubes combined.

9. Change the color of cube1 to "Yellow" and change its depth to 15.

10. Use the box toString() method to show the state of each object.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!