Java Reference
In-Depth Information
Figure 14.2. The Firework class "inherits" classification constants by implementing
the ClassificationConstants interface.
CHALLENGE 14.3
Suppose that you want to use constructors to establish the default classification of
afirework as DISPLAY . Write constructors for Firework that ensure this, and
make them collaborate so that the one-parameter constructor uses the two-parameter
constructor.
Changing the constructors for the Firework class forces us to consider changing
the constructors for its subclass, Fountain .
CHALLENGE 14.4
Suppose that you want the Fountain class to abide by the decision that the default
classification of a firework is DISPLAY . It is better not have this decision appear
twice in the code. Write the constructors for Fountain so that they collaborate
effectively with the superclass constructors, including observance of the superclass's
ideas about defaults.
Search WWH ::




Custom Search