November 2002
Intermediate to advanced
240 pages
5h 9m
English
The two implementations of times() are remarkably similar:
Franc
Franc times(int multiplier) { return new Franc(amount * multiplier); }
Dollar
Franc
Dollar times(int multiplier) { return new Dollar(amount * multiplier); }
We can take a step toward reconciling them by making them both return a Money:
Franc
Money times(int multiplier) { return new Franc(amount * multiplier); } ...