public boolean equals(Object anObject) { if (isZero()) if (anObject instanceof IMoney) return ((IMoney) anObject).isZero(); if (anObject instanceof Money) { Money aMoney = (Money) anObject; return aMoney.currency().equals(currency()) && amount() == aMoney.amount(); } return false; }
@Override public boolean equals(Object o) { if (o == null) { return false; } if (this == o) { return true; } if (!(o instanceof Money)) { return false; } Money money = (Money) o; return amount == money.amount && currency().equals(money.currency()); }
public IMoney addMoney(Money m) { if (m.currency().equals(currency())) return new Money(amount() + m.amount(), currency()); return MoneyBag.create(this, m); }
@Test public void testReduce() { Money dollar = Money.dollar(1); Money reduce = dollar.reduce(new Bank(), dollar.currency()); assertEquals(dollar, reduce); }