AP Computer Science --- Haas --- SizeableInterface

Implement the Sizeable interface in the classes: Sphere, Cylinder, Cone, and RectangularPrism. The Sizeable interface has two methods:

In case you forgot how to find Volume and Surface Area check out the links below:
http://math.about.com/library/blmeasurement.htm
http://dpi.wi.gov/oea/pdf/kce_mathref_f02.pdf

Below is the partially complete code for the Sizeable interface, the classes: Sphere, Cylinder, Cone, RectangularPrism, and a Tester.



/** <<< This Code Is Complete!!! >>>
 * Create four classes which Implement this interface:
 * Sphere, Cylinder, Cone, RectangularPrism
 */
public interface Sizeable
{
    double volume();  // finds the volume of a solid
    double surfaceArea();  // finds the surface area of a solid
}


/**
 * Complete the class Sphere below:
 *    class Sphere implements the Sizeable interface
 *    Sphere has a 1 parameter constructor which initializes radius
 */
public class Sphere implements Sizeable
{
    private int radius;
    
   /**
    * write a 1 paramater constructor to initialize radius
    */

    
   /**
    * complete the method volume, which returns the volume 
    * of the sphere rounded to 2 decimal places
    */
    public double volume() {
        
    }
    
   /** 
    * complete the method surfaceArea, which returns the 
    * surface area of the sphere rounded to 2 decimal places
    */
    public double surfaceArea() {
       
    }
    
    /** 
     * Write the method toString which returns a string with:
     * the type of object, its radius, volume, and surface area.
     */
    public String toString() {
    
    }   
}


/**
 * Complete the class Cylinder below:
 * class Cylinder implements the Sizeable interface
 */
public class Cylinder implements Sizeable
{
    private int radius;
    private int height;
    
   /**
    * write a 2 parameter constructor which initializes radius and height
    */

    
   /**
    * Write the method volume, which returns the volume 
    * of the Cylinder rounded to 2 decimal places
    */
    public double volume() {

    }
    
   /** 
    * Write the method surfaceArea, which returns the 
    * surface area of the Cylinder rounded to 2 decimal places
    */
    public double surfaceArea() {

    }
    
    /** 
     * Write the method toString which returns a string with:
     * the type of object, its radius, height, volume, surface area.
     */
    public String toString() {

    }   
}


/**
 * Complete the class Cone below:
 * class Cone implements the Sizeable interface
 */
public class Cone implements Sizeable
{
    private int radius;
    private int height;
    
   /**
    * write a 2 parameter constructor which initializes radius and height
    */
    
   /**
    * write the method volume, which returns the volume 
    * of the Cone rounded to 2 decimal places
    */
    public double volume() {

    }
    
   /** 
    * write the method surfaceArea, which returns the 
    * surface area of the Cone rounded to 2 decimal places
    */
    public double surfaceArea() {

    }
    
    /** 
     * Write the method toString which returns a string with:
     * the type of object, its radius, height, volume, surface area.
     */
    public String toString() {

    }   
}


/**
 * Complete the class RectangularPrism below:
 * class RectangularPrism implements the Sizeable interface
 */
public class RectangularPrism implements Sizeable
{
    private int length;
    private int width;
    private int height;
    
   /**
    * write a 3 parameter constructor which initializes length, width and height
    */
    
   /**
    * write the method volume, which returns the volume 
    * of the RectangularPrism rounded to 2 decimal places
    */
    public double volume() {

    }
    
   /** 
    * write the method surfaceArea, which returns the 
    * surface area of the RectangularPrism rounded to 2 decimal places
    */
    public double surfaceArea() {

    }
    
    /** 
     * Write the method toString which returns a string with:
     * the type of object, its length, width, height, volume, surface area.
     */
    public String toString() {

    }   
}


/**  <<< This code is complete >>>
 * Below is a tester for the shapes:  
 *   Sphere, Cylinder, Cone, and RectangularPrism
 * 
 * It creates 1 example of each type of shape and prints its 
 * the dimensions, volume, and surface area
 */
public class ShapesTester 
{  
  public static void main(String[] args)
  {
    Sphere s1 = new Sphere(10);
    // Prints >>> I am a Sphere: radius=10 volume=4188.79 surface area=1256.64
    System.out.println(s1.toString());
        
    Cylinder c1 = new Cylinder(5,3);
    // Prints >>> I am a Cylinder: radius=5 height=3 volume=235.62 surface area=251.33
    System.out.println(c1.toString());
        
    Cone cn1 = new Cone(5,3);
    // Prints >>> I am a Cone: radius=5 height=3 volume=78.54 surface area=170.13
    System.out.println(cn1.toString());
       
    RectangularPrism p1 = new RectangularPrism(3,4,5);
    // Prints >>> I am a Rectangular Prism: length=3 width=4 height=5 volume=60.0 surface area=94.0
    System.out.println(p1.toString());
  }
}