November 2002
Intermediate to advanced
240 pages
5h 9m
English
The two subclasses, Dollar and Franc, have only their constructors. But because a constructor is not reason enough to have a subclass, we want to delete the subclasses.
We can replace references to the subclasses with references to the superclass without changing the meaning of the code. First Franc:
Franc
static Money franc(int amount){ return new Money(amount, "CHF"); }
Then Dollar:
Dollar