@Test public void plus(){ { final Amount amount = new Amount(1112223334,99); final Amount result = amount.plus(new Amount(332221114,01)); assertEquals(1444444449.00, result.toDouble(), DELTA); } { final Amount amount = new Amount(100000,0); final Amount result = amount.plus(new Amount(0,-1)); assertEquals(99999.99, result.toDouble(), DELTA); } { final Amount max = new Amount(Amount.maxValue()); final Amount badDelta = new Amount(0,1); try{ max.plus(badDelta); fail("Amount.RangeExc expected"); }catch(Amount.RangeExc expected){} } { final Amount min = new Amount(Amount.minValue()); final Amount badDelta = new Amount(0,-1); try{ min.plus(badDelta); fail("(Amount.RangeExc expected"); }catch(Amount.RangeExc expected){} } }
public Amount plus(final Amount other) { final double doubleResult = this.toDouble() + other.toDouble(); final Amount result = new Amount(doubleResult); return result; }
Amount { public Amount plus(final Amount other) { final double doubleResult = this.toDouble() + other.toDouble(); final Amount result = new Amount(doubleResult); return result; } }
Amount { public Amount plus(final Amount other) { final double doubleResult = this.toDouble() + other.toDouble(); final Amount result = new Amount(doubleResult); return result; } @SuppressWarnings("unused") private  Amount();  Amount(final int euros, final int cents);  Amount(final double euros); }
Amount { public Amount plus(final Amount other) { final double doubleResult = this.toDouble() + other.toDouble(); final Amount result = new Amount(doubleResult); return result; } @SuppressWarnings("unused") private  Amount();  Amount(final int euros, final int cents);  Amount(final double euros); static double maxValue(); static double minValue(); long getCents(); Amount plus(final Amount other); @Override boolean equals(final Object other); @Override int hashCode(); int compareTo(final Amount other); Amount minus(final Amount other); Amount times(final double factor); double toDouble(); String toString(); }
Amount { public Amount plus(final Amount other) { final double doubleResult = this.toDouble() + other.toDouble(); final Amount result = new Amount(doubleResult); return result; } @SuppressWarnings("unused") private  Amount();  Amount(final int euros, final int cents);  Amount(final double euros); static double maxValue(); static double minValue(); long getCents(); Amount plus(final Amount other); @Override boolean equals(final Object other); @Override int hashCode(); int compareTo(final Amount other); Amount minus(final Amount other); Amount times(final double factor); double toDouble(); String toString(); static final Amount ZERO; }