01: import java.util.HashSet;
02: import java.util.Iterator;
03: import java.util.Set;
04: 
05: /**
06:    A program to test hash codes of coins.
07: */
08: public class HashCodeTester
09: {
10:    public static void main(String[] args)
11:    {
12:       Coin coin1 = new Coin(0.25, "quarter");
13:       Coin coin2 = new Coin(0.25, "quarter");
14:       Coin coin3 = new Coin(0.05, "nickel");
15: 
16:       System.out.println("hash code of coin1=" 
17:             + coin1.hashCode());
18:       System.out.println("hash code of coin2=" 
19:             + coin2.hashCode());
20:       System.out.println("hash code of coin3=" 
21:             + coin3.hashCode());
22: 
23:       Set<Coin> coins = new HashSet<Coin>();
24:       coins.add(coin1);
25:       coins.add(coin2);
26:       coins.add(coin3);
27: 
28:       for (Coin c : coins)
29:          System.out.println(c);
30:    }
31: }