Fill in the blanks to complete classes Sphere and Calculation below. Class Calculation is the client of Sphere. Read through both incomplete classes before you start writing. It may be helpful to complete class Sphere before class Calculation. Pay attention to the comments.
public class Calculation {
public static void main(String[] args) {
// create two Sphere objects
________________ ball = ________________________(4.0,"ball");
________________ orange = ________________________(4.0,"orange");
// compute volume of the ball
________________ ballVol = ________________________;
// print a description of the orange
___________________________________________________;
} //method main
} //class Calculation
public class Sphere {
____________ double radius; // radius of sphere
____________ ____________ type; // what the sphere is
// Constructor: assign values to the two instance variables of the Sphere
____________ ____________(____________ r, ____________ t) {
____________________________________________________________________
| |
| |
| |
|____________________________________________________________________|
} //constructor
// instance method getVolume for calculating volume of the Sphere
____________________________________________________________________
| |
| |
| |
| |
|____________________________________________________________________|
// define a toString method for showing the type and radius of the Sphere
____________________________________________________________________
| |
| |
| |
| |
|____________________________________________________________________|
} //class Sphere