Question: Excirse # 2 : Create the following Parent Class Shape 3 D ( getVolume ( ) and getSurfaceArea ( ) return 0 . 0 )
Excirse #:
Create the following Parent Class ShapeD getVolume and getSurfaceArea return
tableShapeD color: String ShapeDString setColor: String setColorString:void toString:String getVolume:double getSurfaceArea: double
Create three classes that inherit from the class ShapeD 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 TestDShapes 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 ShapeD
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.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
