1: package junit.samples.money; 2: 3: /** 4: * The common interface for simple Monies and MoneyBags 5: * 6: */ 7: public interface IMoney { 8: /** 9: * Adds a money to this money. 10: */ 11: public abstract IMoney add(IMoney m); 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: * Adds a MoneyBag to this money. This is a helper method for 19: * implementing double dispatch 20: */ 21: public abstract IMoney addMoneyBag(MoneyBag s); 22: /** 23: * Tests whether this money is zero 24: */ 25: public abstract boolean isZero(); 26: /** 27: * Multiplies a money by the given factor. 28: */ 29: public abstract IMoney multiply(int factor); 30: /** 31: * Negates this money. 32: */ 33: public abstract IMoney negate(); 34: /** 35: * Subtracts a money from this money. 36: */ 37: public abstract IMoney subtract(IMoney m); 38: /** 39: * Append this to a MoneyBag m. 40: */ 41: public abstract void appendTo(MoneyBag m); 42: }