Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 @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());
 }
Esempio n. 3
0
 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);
 }