CashRegisterTester.java.html

  1  /**
  2     A class to test the CashRegister class.
  3  */
  4  public class CashRegisterTester
  5  {
  6     public static void main(String[] args)
  7     {
  8        final Coin DOLLAR = new Coin(1.0, "Dollar");
  9        final Coin QUARTER = new Coin(0.25, "Quarter");
 10  
 11        CashRegister register = new CashRegister();
 12  
 13        register.recordPurchase(1.95);
 14        register.recordPurchase(1.40);
 15        register.receivePayment(3, DOLLAR);
 16        register.receivePayment(2, QUARTER);
 17  
 18        double change = register.giveChange();
 19  
 20        System.out.println(change);      
 21        System.out.println("Expected: 0.15");          
 22     }
 23  }