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 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
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