Modify the giveChange method of the CashRegister class so that it returns the number of coins of a particular type to return:

int giveChange(Coin coinType)

The caller needs to invoke this method for each coin type, in decreasing value.

Complete the following files:

CashRegister.java

CashRegisterTester2.java

Coin.java

Use the following file:

CashRegisterTester.java

/**
   This program tests the CashRegister class.
*/
public class CashRegisterTester
{
   public static void main(String[] args)
   {
      final double PENNY_VALUE = 0.01;
      final double NICKEL_VALUE = 0.05;
      final double DIME_VALUE = 0.1;
      final double QUARTER_VALUE = 0.25;

      CashRegister myRegister = new CashRegister();
      myRegister.recordPurchase(0.82);
      myRegister.enterPayment(1.00);

      Coin[] coinTypes = new Coin[] 
      {
         new Coin(QUARTER_VALUE, "quarter"),
         new Coin(DIME_VALUE, "dime"),
         new Coin(NICKEL_VALUE, "nickel"),
         new Coin(PENNY_VALUE, "penny")
      };

      int[] expected = { 0, 1, 1, 3 };

      for (int i = 0; i < coinTypes.length; i++)
      {
         Coin c = coinTypes[i];
         int change = myRegister.giveChange(c);
         System.out.println(c.getName() + ": " + change);
         System.out.println("Expected: " + expected[i]);
      }
   }
}