Question: Excirse # 2 : Create the following Parent Class Shape 3 D ( getVolume ( ) and getSurfaceArea ( ) return 0 . 0 )

Excirse #2:
Create the following Parent Class Shape3D (getVolume() and getSurfaceArea() return 0.0)
\table[[Shape3D],[- color: String],[+ Shape3D(String)],[+ setColor(): String],[+ setColor(String):void],[+ toString():String],[+ getVolume():double],[+ getSurfaceArea(): double]]
Create three classes that inherit from the class Shape3D (Ball, Box and Cone)
Add the appropriate attributes to each class and implement the constructor that calls the super constructor.
Override the toString() method of each class.
Override the getVolume() method to calculate and return the volume of each class.
Override the getSurfaceArea() method to calculate and return the surface area of each class.
Create a Test3DShapes class to test what you have done.
Create three objects, one of type Ball, one or type Box, and one of type Cone
Add the three objects to an arraylist of Shape3D.
Loop through all objects of the arraylist and print all objects using the toString method, then print the volume and the surface area of each shape method within the same loop.
Print the object with the biggest volume.
Print the total surface area for all shapes.
Excirse # 2 : Create the following Parent Class

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 Programming Questions!