Class Snack
java.lang.Object
|
+--Snack
- public class Snack
- extends java.lang.Object
- implements java.lang.Comparable
Constructor Summary |
Snack(java.lang.String tradeName,
java.util.Vector ingredients,
double priceInDollarsAndCents)
This is the constructor of a Snack |
Method Summary |
int |
compareTo(java.lang.Object anotherSnack)
This compares two Snacks based on their tradeNames
It returns 0 if the two Snacks have the same tradeName
and non-0, otherwise. |
java.util.Vector |
getIngredients()
This returns the ingredients of the Snack, as a list of Strings stored
within a Vector. |
double |
getPriceInDollarsAndCents()
This is returns the selling price of the Snack |
java.lang.String |
getTradeName()
This is returns the trade name of a Snack |
java.lang.String |
toString()
Returns a String representation of a Snack including the
tradeName, ingredients and priceInDollarsAndCents |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Snack
public Snack(java.lang.String tradeName,
java.util.Vector ingredients,
double priceInDollarsAndCents)
- This is the constructor of a Snack
getIngredients
public java.util.Vector getIngredients()
- This returns the ingredients of the Snack, as a list of Strings stored
within a Vector.
- Returns:
- the height of the Tree in whole feet.
getPriceInDollarsAndCents
public double getPriceInDollarsAndCents()
- This is returns the selling price of the Snack
- Returns:
- the selling price of the Snack in dollars, with cents as
a fraction
getTradeName
public java.lang.String getTradeName()
- This is returns the trade name of a Snack
- Returns:
- the trade name of a Snack
compareTo
public int compareTo(java.lang.Object anotherSnack)
- This compares two Snacks based on their tradeNames
It returns 0 if the two Snacks have the same tradeName
and non-0, otherwise.
- Specified by:
- compareTo in interface java.lang.Comparable
- Returns:
- 0 if the ingredients are the same, non-0 otherwise
toString
public java.lang.String toString()
- Returns a String representation of a Snack including the
tradeName, ingredients and priceInDollarsAndCents
- Overrides:
- toString in class java.lang.Object
- Returns:
- a String containing a representation of the Tree