Money extends Magnitude<Money> { public Money add(final Money money) { assertSameCurrency(money); return newMoney(amount + money.amount); } Money(final double amount, final String currency);  Money(final long amount, final String currency); Money add(final Money money); double doubleValue(); float floatValue(); BigDecimal getAmount(); String getCurrency(); boolean hasSameCurrency(final Money money); int intValue(); @Override boolean isEqualTo(final Money magnitude); boolean isGreaterThanZero(); @Override boolean isLessThan(final Money magnitude); boolean isLessThanZero(); boolean isZero(); long longValue(); Money subtract(final Money money); @Override boolean equals(final Object other); boolean equals(final Money other); @Override int hashCode(); @Override String toString();  }
@Test public void testAdd() { final Money m1 = new Money(110, "pds"); final Money m2 = new Money(220, "pds"); final Money m3 = m1.add(m2); assertEquals(330.0, m3.doubleValue(), 0.0); }
@Test(expected = IllegalArgumentException.class) public void testAddThrowsExceptionForDifferentCurrencies() { final Money m1 = new Money(100, "pds"); final Money m2 = new Money(200, "uds"); m1.add(m2); }