November 2002
Intermediate to advanced
240 pages
5h 9m
English
We need to implement Sum.plus() to finish Expression.plus, and then we need Expression.times(), and then we’re finished with the whole example. Here’s the test for Sum.plus():
public void testSumPlusMoney() { Expression fiveBucks= Money.dollar(5); Expression tenFrancs= Money.franc(10); Bank bank= new Bank(); bank.addRate("CHF", "USD", 2); Expression sum= new Sum(fiveBucks, tenFrancs).plus(fiveBucks); Money result= bank.reduce(sum, "USD"); assertEquals(Money.dollar(15), result); }
We could have created a Sum by adding ...