Class Purse
java.lang.Object
|
+----Purse
- public class Purse
- extends java.lang.Object
This class keeps any number of coins together in the purse.
-
Purse()
- constructs an empty purse
-
add(Coin)
- Adds a coin to the purse
-
count()
- Counts the number of coins in the purse.
-
count(Coin)
- Counts the number of coins in the purse that match a given coin.
-
find(Coin)
- Tests whether the purse has a coin that matches a given coin.
-
getMaximum()
- Finds the coin with teh largest value.
-
getTotal()
- Get the total value of the coins in the purse.
Purse
public Purse()
- constructs an empty purse
add
public void add(Coin aCoin)
- Adds a coin to the purse
- Parameters:
- aCoin - the coin to add
getTotal
public double getTotal()
- Get the total value of the coins in the purse.
- Returns:
- the sum of all the coins
count
public int count()
- Counts the number of coins in the purse.
- Returns:
- the number of coins
find
public boolean find(Coin aCoin)
- Tests whether the purse has a coin that matches a given coin.
- Parameters:
- aCoin - the coin to match
count
public int count(Coin aCoin)
- Counts the number of coins in the purse that match a given coin.
- Parameters:
- aCoin - the coin to match
- Returns:
- the number of coins equal to aCoin
getMaximum
public Coin getMaximum()
- Finds the coin with teh largest value.
- Returns:
- a coin with maximum value in this purse