Viewing file: comp249/assignment1/BunnyPaw.java | Back to directory listing
Author: Loren Segal | Last modified: February 21 2006 12:00 am | Download

 
/**
 * The BunnyPaw is part of the Doodad collection
 * 
 * @author Loren Segal 
 * @version 1.0
 */
public class BunnyPaw extends Doodad implements Locomote
{
    //=== Locomote Interface ===//
    private static int      MOVE_DISTANCE = 4;
    private static String   MOVE_TYPE = "Roll";
    
    /**
    * Part of the Locomote interface; 
    * returns the move type of the BunnyPaw.
    *
    * @return the move style for the BunnyPaw, currently: Roll
    */
    public String style()
    {
        return MOVE_TYPE;
    }
 
    /**
     * Part of the Locomote interface;
     * returns the move distance of the BunnyPaw.
     *
     * @return the move distance of the BunnyPaw, currently: 4 meters
     */    
    public int howFar()
    {
        return MOVE_DISTANCE;
    }
    //=== End Locomote Interface ===//
    
    /**
     * Another way to calculate price for a BunnyPaw is through
     * this method which accepts a scaled integer and returns 
     * a price based on the move distance times the scale.
     * 
     * @param scale the multiplier value to determine price
     * @return the price based on howFar() * scale
     */
    public double calculatePrice(int scale)
    {
        return howFar() * scale;
    }
    
    public String toString()
    {
        return super.toString() + "For all Ages\n";
    }
 
    //=== Constructors ===//
    /**
     * Creates a BunnyPaw with a name;
     * Minimum age will be Doodad default
     * 
     * @param newName Name of the BunnyPaw
     */
    public BunnyPaw(String name)
    {
        super(name);
    }
    
    /**
     * Creates a BunnyPaw with a name and minimum age
     * 
     * @param newName Name of the BunnyPaw
     * @param minAge Minimum age for the BunnyPaw's user
     */
    public BunnyPaw(String name, int minAge)
    {
        super(name, minAge);
    }
    //=== End Constructors ===//
 
}