foodManagement
Class Food

java.lang.Object
  extended by foodManagement.Food
All Implemented Interfaces:
Listable

public class Food
extends java.lang.Object
implements Listable

An IMMUTABLE class that represents an item that might be part of an entree in a restaurant. (For example, Toast or Coffee.) A food object has a name (String), a wholesale cost measured in pennies (int), a retail price measured in pennies (int), and a small picture that depicts the item (java.awt.Image).

Note that the constructor is private, so the only available Food objects are those that are found in the public static array of Food objects called FOOD_OBJECTS. (You cannot use "new" to instantiate a Food object, you must use the ones that are already in the FOOD_OBJECTS array.)


Field Summary
static Food[] FOOD_OBJECTS
          This array is populated with Food items that are available for use.
 
Method Summary
 boolean equals(Food other)
          Checks if the current object is equal to the parameter.
 java.awt.Image getImage()
          Getter for the Image associated with this food.
 java.lang.String getName()
          Getter for the name of this food.
 int getRetailValue()
          Getter for the retail cost of this food, measured in pennies.
 int getWholesaleCost()
          Getter for the wholesale cost of this food, measured in pennies.
 java.lang.String toString()
          Returns the name of the food.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FOOD_OBJECTS

public static final Food[] FOOD_OBJECTS
This array is populated with Food items that are available for use. Use this array any time you need a Food object. The constructor for the Food class is private, so the elements of this array are the only Food objects available. (You cannot create new ones.)

Method Detail

getImage

public java.awt.Image getImage()
Getter for the Image associated with this food. (It's a very small picture of the food item.)

Returns:
a picture representing this item

getName

public java.lang.String getName()
Getter for the name of this food.

Specified by:
getName in interface Listable
Returns:
the name of this food

getWholesaleCost

public int getWholesaleCost()
Getter for the wholesale cost of this food, measured in pennies.

Specified by:
getWholesaleCost in interface Listable
Returns:
wholesale cost for this food item in pennies.

getRetailValue

public int getRetailValue()
Getter for the retail cost of this food, measured in pennies.

Specified by:
getRetailValue in interface Listable
Returns:
retail cost for this food item in pennies.

equals

public boolean equals(Food other)
Checks if the current object is equal to the parameter. Note: only the NAMES of the foods are compared. If the two foods have the same name, they are considered equal!

Parameters:
other - Food item to be compared with the current object
Returns:
true if the two Foods have the same name, false otherwise

toString

public java.lang.String toString()
Returns the name of the food.

Specified by:
toString in interface Listable
Overrides:
toString in class java.lang.Object
Returns:
the name of the food


Web Accessibility