previous |
start |
next
Counting
public class Purse
{
public int count(Coin aCoin)
{
int matches = 0;
for (int i = 0; i < coins.size(); i++)
{
Coin c =(Coin)coins.get(i);
if (c.equals(aCoin)) matches++; //found a match
}
return matches;
}
...
}
previous |
start |
next