/**
* A SnuffJacket is the adult version of the Flubber Doodad
*
* @author Loren Segal
* @version 1.0
*/
public class SnuffJacket extends Crumpet implements Talker
{
//=== Talker interface constants ===//
private static final String SAY_HI = "Good day fellow traveler";
private static final String SAY_BYE = "Have a nice day";
//=== Constructor defaults ===//
private static final String DEFAULT_NAME = "Snuffer Toy";
private static final double DEFAULT_MANUFACTURING_COST = 99.99;
//=== Price/cost defaults ===//
private static final double DEFAULT_MARKUP = 5.55;
private static final double MANUFACTURING_CUTOFF = 26.99;
//=== Talker interface ===//
/**
* Part of the Talker interface; says hi.
*
* @return Currently returns "Good day fellow traveler"
*/
public String sayHi()
{
return SAY_HI;
}
/**
* Part of the Talker interface; says bye.
*
* @return Currently returns "Have a nice day"
*/
public String sayBye()
{
return SAY_BYE;
}
//=== End Talker interface ===//
/**
* Returns a price based on the Crumpet's calculatePrice but adds
* an additional markup value.
*
* @param markup A markup value
*
* @return SnuffJacket price = Crumpet price + a markup value
*/
public double calculatePrice(double markup)
{
return super.calculatePrice() + markup;
}
/**
* Returns the SnuffJacket price. If the manufacturing cost
* is smaller than a cutoff (currently 26.99), then a markup
* (currently 5.55) will be added to the price. Otherwise the
* price will be based on the Crumpet price.
*
* @return SnuffJacket price
*/
public double calculatePrice()
{
if (this.getManufacturingCost() < MANUFACTURING_CUTOFF)
{
return calculatePrice(DEFAULT_MARKUP);
}
else
{
return super.calculatePrice();
}
}
/**
* Returns the regular string representation plus an example of
* the SnuffJacket's sayHi() method.
*/
public String toString()
{
return super.toString() + sayHi() + "\n";
}
//=== Constructors ===//
/**
* Create a SnuffJacket with a name and manufacturing cost
*
* @param name Name of the SnuffJacket
* @param manufacturingCost manufacturing cost of the SnuffJacket
*/
public SnuffJacket(String name, double manufacturingCost)
{
super(name, manufacturingCost);
}
/**
* Create a SnuffJacket with default name and manufacturing cost;
* currently "Snuffer Toy" and 99.99 respectively.
*/
public SnuffJacket()
{
super(DEFAULT_NAME, DEFAULT_MANUFACTURING_COST);
}
//=== End Constructors ===//
} Powered by
GeSHi Syntax Highlighting software.
Author of all (other) material unless otherwise specified:
Loren Segal. Copyright 2005.