1
|
 |
package com.instantiations.example.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
|
|
* Adds a simple Money to this money. This is a helper method for
|
13
|
|
* implementing double dispatch
|
14
|
|
*/
|
15
|
   |
public abstract IMoney addMoney(Money m);
|
16
|
|
/**
|
17
|
|
* Adds a MoneyBag to this money. This is a helper method for
|
18
|
|
* implementing double dispatch
|
19
|
|
*/
|
20
|
   |
public abstract IMoney addMoneyBag(MoneyBag s);
|
21
|
|
/**
|
22
|
|
* Tests whether this money is zero
|
23
|
|
*/
|
24
|
  |
public abstract boolean isZero();
|
25
|
|
/**
|
26
|
|
* Multiplies a money by the given factor.
|
27
|
|
*/
|
28
|
   |
public abstract IMoney multiply(int factor);
|
29
|
|
/**
|
30
|
|
* Negates this money.
|
31
|
|
*/
|
32
|
  |
public abstract IMoney negate();
|
33
|
|
/**
|
34
|
|
* Subtracts a money from this money.
|
35
|
|
*/
|
36
|
   |
public abstract IMoney subtract(IMoney m);
|
37
|
|
/**
|
38
|
|
* Append this to a MoneyBag m.
|
39
|
|
*/
|
40
|
   |
public abstract void appendTo(MoneyBag m);
|
41
|
|
}
|