/**
* Abstract class Doodad - Children's category Widget
*
* @author Loren Segal
* @version 1.0
*/
public abstract class Doodad extends Widget
{
// Default Constants
private static final int AGE_FACTOR = 12;
private static final int MIN_AGE = 2;
private static final String DEFAULT_NAME = "BGD Doodad";
// Class members
private int minAge;
/**
* Creates a new Doodad with a minimum age.
*
* @param newMinAge Minimum age for Doodad
*/
public Doodad(int newMinAge)
{
this(DEFAULT_NAME, newMinAge);
}
/**
* Creates a new Doodad with a name.
*
* @param newName Name for Doodad
*/
public Doodad(String newName)
{
this(newName, MIN_AGE);
}
/**
* Creates a new Doodad with a name and minimum age.
*
* @param newName Name for Doodad
* @param newMinAge Minimum age for Doodad
*/
public Doodad(String newName, int newMinAge)
{
super(newName);
setMinAge(newMinAge);
}
/**
* Calculates the price for a Widget based on Wally's formula
*
* @return the price of a Doodad
*/
public double calculatePrice()
{
return (Math.abs(this.getMinAge()) * AGE_FACTOR *
Math.pow(2, this.getName().length())) % 100;
}
/**
* Gets the minimum age requirement for a Doodad
*
* @return minimum age
*/
public int getMinAge()
{
return this.minAge;
}
/**
* Sets the minimum age requirement for a Doodad
*
* @param newMinAge minimum age
*/
public void setMinAge(int newMinAge)
{
this.minAge = newMinAge;
}
} Powered by
GeSHi Syntax Highlighting software.
Author of all (other) material unless otherwise specified:
Loren Segal. Copyright 2005.