Class Implementation


Class Structure: Adding Methods

 
/** Class documentation goes here.
 */
public class Ball
{
  // State: instance variables go here.
    private Color ballColor;
    private String type;
    private float diameter;

  // Constructors

    /**  Constructor documentation goes here.
     */
    public Ball(Color col, String category, float diam)
    {
        // initialise instance variables
        // (code missing)
    }

  // Methods

    /** Method documentation goes here.
     */
    public void throw()
    {
        // method code goes here
    }

    /** Method documentation goes here.
     */
    public Color getColor()
    {
        return this.ballColor;
    }

    /** Method documentation goes here.
     */
    public float getRadius()
    {
        return this.diameter / 2.0;
    }

}

Alyce Brady, Kalamazoo College