eShopper
Class eShopperIngredient

java.lang.Object
  extended byeShopper.eShopperNode
      extended byeShopper.eShopperIngredient

public class eShopperIngredient
extends eShopperNode

This class is for the ingredients in a list. It has no children. It is a subclass of eShopperNode.

Author:
Jim Laing

Constructor Summary
eShopperIngredient(int nodeID, int ingredientID, int listID, eShopperDB db, float qty, int unitid)
           
 
Method Summary
 boolean canCombineWith(eShopperIngredient i)
          This decides whether the quantity of this Ingredient can be combined with the quantity of another.
 void combineWith(eShopperIngredient i, boolean largest)
          This combines the quantities of two Ingredients.
 java.util.Vector getChildren()
          This returns the children of the Ingredient.
 java.lang.String getDate()
          This returns the date associated with the Ingredient.
 java.lang.String getDescription()
          This accesses the description associated with the Ingredient.
 java.lang.String getName()
          This is for getting the name of the Ingredient.
 float getQuantity()
          This accesses the quantity of the Ingredient in the list.
 int getUnitID()
          This accesses the UnitID of the Ingredient.
 int ingredientID()
          This accesses the unique ingredientID of the Ingredient.
 int nodeID()
          This accesses the nodeID of the Ingredient
 java.lang.String toString()
          This overloads the toString() method, and returns the name and quantity of the Ingredient.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

eShopperIngredient

public eShopperIngredient(int nodeID,
                          int ingredientID,
                          int listID,
                          eShopperDB db,
                          float qty,
                          int unitid)
Method Detail

getChildren

public java.util.Vector getChildren()
This returns the children of the Ingredient.

Specified by:
getChildren in class eShopperNode
Returns:
Always returns null, because an Ingredient cannot have any children.

toString

public java.lang.String toString()
This overloads the toString() method, and returns the name and quantity of the Ingredient.

Specified by:
toString in class eShopperNode
Returns:
a String representation of a node

getName

public java.lang.String getName()
This is for getting the name of the Ingredient.

Returns:
A string representation of the Ingredient's name.

nodeID

public int nodeID()
This accesses the nodeID of the Ingredient

Specified by:
nodeID in class eShopperNode
Returns:
The nodeID of the Ingredient.

ingredientID

public int ingredientID()
This accesses the unique ingredientID of the Ingredient.

Returns:
The ingredientID.

getDescription

public java.lang.String getDescription()
This accesses the description associated with the Ingredient.

Returns:
A String representation of the Ingredient's description.

getQuantity

public float getQuantity()
This accesses the quantity of the Ingredient in the list.

Returns:
The quantity of the Ingredient in the list.

getUnitID

public int getUnitID()
This accesses the UnitID of the Ingredient.

Returns:
The UnitID of the Ingredient.

getDate

public java.lang.String getDate()
This returns the date associated with the Ingredient.

Specified by:
getDate in class eShopperNode
Returns:
A string representation of the date, or null if it's unassigned.

canCombineWith

public boolean canCombineWith(eShopperIngredient i)
This decides whether the quantity of this Ingredient can be combined with the quantity of another.

Parameters:
i - The Ingredient with which this one should be combined.
Returns:
true if the Ingredients can be combined, false if not.

combineWith

public void combineWith(eShopperIngredient i,
                        boolean largest)
This combines the quantities of two Ingredients.

Parameters:
i - The Ingredient that this Ingredient should be combined with.
largest - The largest unit of this type.