CashRegisterTester.java.html

  1  /**
  2     This class tests the CashRegister class.
  3  */
  4  public class CashRegisterTester
  5  {
  6     public static void main(String[] args)
  7     {
  8        CashRegister register = new CashRegister();
  9  
 10        register.recordPurchase(0.75);
 11        register.recordPurchase(1.50);
 12        register.receivePayment(2, 0, 5, 0, 0);
 13        System.out.print("Change: ");
 14        System.out.println(register.giveChange());
 15        System.out.println("Expected: 0.25");
 16  
 17        register.recordPurchase(2.25);
 18        register.recordPurchase(19.25);
 19        register.receivePayment(23, 2, 0, 0, 0);
 20        System.out.print("Change: ");
 21        System.out.println(register.giveChange());
 22        System.out.println("Expected: 2.0");
 23     }
 24  }