public class PiggyBank
1: // NOTE: We have substituted the class ArrayBag from Chapter 2
2: // for the class Bag that is used in Chapter 1.
3: /**
4: A class that implements a piggy bank by using a bag.
5: @author Frank M. Carrano
6: @version 4.0
7: */
8: public class PiggyBank
9: {
10: private BagInterface<Coin> coins;
11:
12: public PiggyBank()
13: {
14: coins = new ArrayBag<>();
15: } // end default constructor
16:
17: public boolean add(Coin aCoin)
18: {
19: return coins.add(aCoin);
20: } // end add
21:
22: public Coin remove()
23: {
24: return coins.remove();
25: } // end remove
26:
27: public boolean isEmpty()
28: {
29: return coins.isEmpty();
30: } // end isEmpty
31: } // end PiggyBank