money
Class MoneyBag

java.lang.Object
  extended bymoney.MoneyBag
All Implemented Interfaces:
IMoney

public class MoneyBag
extends Object
implements IMoney

A MoneyBag defers exchange rate conversions. For example adding 12 Swiss Francs to 14 US Dollars is represented as a bag containing the two Monies 12 CHF and 14 USD. Adding another 10 Swiss francs gives a bag with 22 CHF and 14 USD. Due to the deferred exchange rate conversion we can later value a MoneyBag with different exchange rates. A MoneyBag is represented as a list of Monies and provides different constructors to create a MoneyBag.


Constructor Summary
MoneyBag(Money[] bag)
           
MoneyBag(MoneyBag m1, MoneyBag m2)
           
MoneyBag(Money m1, Money m2)
           
MoneyBag(Money m, MoneyBag bag)
           
 
Method Summary
 IMoney add(IMoney m)
          Adds a money to this money.
 IMoney addMoney(Money m)
          Adds a simple Money to this money.
 IMoney addMoneyBag(MoneyBag s)
          Adds a MoneyBag to this money.
 boolean equals(Object anObject)
           
 int hashCode()
           
 boolean isZero()
          Tests whether this money is zero
 IMoney multiply(int factor)
          Multiplies a money by the given factor.
 IMoney negate()
          Negates this money.
 IMoney subtract(IMoney m)
          Subtracts a money from this money.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MoneyBag

public MoneyBag(Money[] bag)

MoneyBag

public MoneyBag(Money m1,
                Money m2)

MoneyBag

public MoneyBag(Money m,
                MoneyBag bag)

MoneyBag

public MoneyBag(MoneyBag m1,
                MoneyBag m2)
Method Detail

add

public IMoney add(IMoney m)
Description copied from interface: IMoney
Adds a money to this money.

Specified by:
add in interface IMoney

addMoney

public IMoney addMoney(Money m)
Description copied from interface: IMoney
Adds a simple Money to this money. This is a helper method for implementing double dispatch

Specified by:
addMoney in interface IMoney

addMoneyBag

public IMoney addMoneyBag(MoneyBag s)
Description copied from interface: IMoney
Adds a MoneyBag to this money. This is a helper method for implementing double dispatch

Specified by:
addMoneyBag in interface IMoney

equals

public boolean equals(Object anObject)

hashCode

public int hashCode()

isZero

public boolean isZero()
Description copied from interface: IMoney
Tests whether this money is zero

Specified by:
isZero in interface IMoney

multiply

public IMoney multiply(int factor)
Description copied from interface: IMoney
Multiplies a money by the given factor.

Specified by:
multiply in interface IMoney

negate

public IMoney negate()
Description copied from interface: IMoney
Negates this money.

Specified by:
negate in interface IMoney

subtract

public IMoney subtract(IMoney m)
Description copied from interface: IMoney
Subtracts a money from this money.

Specified by:
subtract in interface IMoney

toString

public String toString()