Viewing file: comp249/assignment1/Crumpet.java | Back to directory listing
Author: Loren Segal | Last modified: February 20 2006 07:00 pm | Download

 
/**
 * A Crumpet is part of the adult category of the widgets
 * 
 * @author Loren Segal
 * @version 1.0
 */
public class Crumpet extends Widget
{
    //=== Price markup constants ===//
    private final static double PRICE_MARKUP = 26.99;
 
    //=== Class variables ===//
    private double manufacturingCost;
    
    //=== Constructors ===//
    /**
     * Creates a Crumpet with a name and a manufacturing cost
     * 
     * @param name Name of the Crumpet
     * @param newManufacturingCost Manufacturing cost of the Crumpet
     */
    public Crumpet(String name, double newManufacturingCost)
    {
        super(name);
        setManufacturingCost(newManufacturingCost);
    }
    //=== End constructors ===//
    
    //=== Manufcaturing cost get/set methods ===//
    /**
     * Sets the manufacturing cost of the Crumpet
     * 
     * @param cost The new manufacturing cost for the Crumpet
     */
    public void setManufacturingCost(double cost)
    {
        manufacturingCost = cost;
    }
    
    /**
     * Gets the manufacturing cost of the Crumpet
     * 
     * @return Manufacturing cost
     */
    public double getManufacturingCost()
    {
        return manufacturingCost;
    }
    //=== End manufacturing cost get/set methods ===//
    
    /**
     * Returns the price of a Crumpet, manufacturing cost + markup
     * 
     * @return Manufacturing cost + markup (markup is currently 26.99)
     */
    public double calculatePrice()
    {
        return getManufacturingCost() + PRICE_MARKUP;
    }
    
    /**
     * Returns the sale price of a Crumpet
     * 
     * @return Regular price + 20% - 10%
     */
    public double calculateSalePrice()
    {
        double  price  = calculatePrice(),
                twenty = 0.2 * price, 
                ten    = 0.1 * price;
        return price + twenty - ten;
    }
}