Question: Details: Define the following classes with the methods specified. Note that get / set functions are NOT required for this assignment. You can assign all
Details:Define the following classes with the methods specified. Note that getset functionsare NOT required for this assignment. You can assign all values in the constructor.
The ShapeD Class
This is an abstract class that implements the Comparable interfaceContains an abstract method called Volume that returns a double
There are no input parameters to this method
Defines a compareTo method that compares itself to another ShapeD classes
HINT: Remember to implement Comparable with your class name
implements Comparable
HINT: When defining compareTo use ShapeD other as the input parameterCalls the abstract Volume method and compares the result
if this.Volume other.Volume return else if this.Volume other.Volume return else return
The Cuboid class
This extends the ShapeD classContains the following attributes
width integerdepth integerheight integer
Contains a constructor class where width, depth and height are set via input parametersOverrides the Volume method
return width depth height
The Cylinder Class
This extends the ShapeD classContains the following attributes
radius integerheight integer
Contains a constructor class where radius and height are set via input parametersOverrides the Volume method
return Math.PI radius radius height
Test Class
The test class contains your main method.In your main method create a Cuboid and a Cylinder
You can set the dimensions to whatever you want
Use the compareTo method to output which has the greater volume, the cuboid or the cylinder or if they are equal
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
