Java Reference
In-Depth Information
Figure 7.2. Protected visibility lets classes outside your package access your code in ways
that may be inappropriate.
One day, you notice that another developer has subclassed your
SolidRocket
class with a
class she calls
Burrow
. In this class, she has added a
setBurnRate()
method that updates
the burn rate attribute. She needs it because she wants to plot a graph showing several burn
rates and the corresponding rocket thrust. You don't have this method in
Solid-Rocket
.
Her approach fails because you calculate thrust only in the constructor, when you first
receive the burn rate.
This situation comes to your attention when she calls to ask why
the thrust doesn't change after she updates the burn rate.