/**
* Abstract class Widget - Basic entity of the BGD infrastructure
*
* @author Loren Segal
* @version 1.0
*/
public abstract class Widget
{
private String name;
/**
* Creates a widget with a name
*/
public Widget(String newName)
{
setName(newName);
}
/**
* Gets the name of the Widget
*
* @return the widget name
*/
public String getName()
{
return this.name;
}
/**
* Sets the name of the Widget
*
* @param newName the name of the widget
*/
public void setName(String newName)
{
this.name = newName;
}
/**
* Gets the price of the Widget, must be overridden
*
* @return the widget price
*/
public abstract double calculatePrice();
/**
* The object's string representation
*
* @return A string of form: "NAME: PRICE"
*/
public String toString()
{
return "** Big Green Dog Corp **\n" +
getName() + ": " + calculatePrice() + "\n";
}
} Powered by
GeSHi Syntax Highlighting software.
Author of all (other) material unless otherwise specified:
Loren Segal. Copyright 2005.