Class Purse

java.lang.Object
   |
   +----Purse

public class Purse
extends java.lang.Object
This class keeps any number of coins together in the purse.


Constructor Index

 o Purse()
constructs an empty purse

Method Index

 o add(Coin)
Adds a coin to the purse
 o count()
Counts the number of coins in the purse.
 o count(Coin)
Counts the number of coins in the purse that match a given coin.
 o find(Coin)
Tests whether the purse has a coin that matches a given coin.
 o getMaximum()
Finds the coin with teh largest value.
 o getTotal()
Get the total value of the coins in the purse.

Constructors

 o Purse
 public Purse()
constructs an empty purse

Methods

 o add
 public void add(Coin aCoin)
Adds a coin to the purse

Parameters:
aCoin - the coin to add
 o getTotal
 public double getTotal()
Get the total value of the coins in the purse.

Returns:
the sum of all the coins
 o count
 public int count()
Counts the number of coins in the purse.

Returns:
the number of coins
 o find
 public boolean find(Coin aCoin)
Tests whether the purse has a coin that matches a given coin.

Parameters:
aCoin - the coin to match
 o 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
 o getMaximum
 public Coin getMaximum()
Finds the coin with teh largest value.

Returns:
a coin with maximum value in this purse