Question: create a Java Class called Sphere. The class should have the following: Constructor: New() Zero parameter. Creates a Sphere with a radius of zero Constructor:
create a Java Class called Sphere. The class should have the following:
Constructor: New() Zero parameter. Creates a Sphere with a radius of zero
Constructor: New(double) Creates a Sphere with the initial radius specified. If the radius specified is less than zero, the Sphere should be constructed with a radius of Zero
Methods:
double volume() Should return the volume of the Sphere
double surfaceArea() Should return the surface area of the Sphere
setRadius( double NewRadius) Should set the radius of the Sphere to the NewRadius provided NewRadius >= 0. If NewRadius <0, no change to the Sphere.
double getRadius( ) Should return the radius of the Sphere
String toString() should return the String representation of the Sphere
Sphere needs to implement the Comparable interface. The comparison should be based upon the size of the Radius.
You must include a main method with appropriate test(s). Remember what an appropriate level of testing includes.
Your Sphere must also include javadoc comments and tags for the class, and all methods and constructors.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
