View Javadoc
1   package junit.samples.money;
2   
3   /**
4    * The common interface for simple Monies and MoneyBags
5    */
6   public interface IMoney {
7       /**
8        * Adds a money to this money.
9        */
10      public abstract IMoney add(IMoney m);
11  
12      /**
13       * Adds a simple Money to this money. This is a helper method for
14       * implementing double dispatch
15       */
16      public abstract IMoney addMoney(Money m);
17  
18      /**
19       * Adds a MoneyBag to this money. This is a helper method for
20       * implementing double dispatch
21       */
22      public abstract IMoney addMoneyBag(MoneyBag s);
23  
24      /**
25       * Tests whether this money is zero
26       */
27      public abstract boolean isZero();
28  
29      /**
30       * Multiplies a money by the given factor.
31       */
32      public abstract IMoney multiply(int factor);
33  
34      /**
35       * Negates this money.
36       */
37      public abstract IMoney negate();
38  
39      /**
40       * Subtracts a money from this money.
41       */
42      public abstract IMoney subtract(IMoney m);
43  
44      /**
45       * Append this to a MoneyBag m.
46       * appendTo() needs to be public because it is used
47       * polymorphically, but it should not be used by clients
48       * because it modifies the argument m.
49       */
50      public abstract void appendTo(MoneyBag m);
51  }