Analyzing Method Visibility
Using Private "Helper" Methods
AquaFish class currently has two private "helper"
initPos, which determine
the initial size and an initial location
and direction for a newly constructed fish. All other methods
are public, and all data members are private.
AquaFish class has many observer methods (such as
Could any of them be private without affecting the rest of the program?
If so, would it be a good idea to make them private?
Does the fact that the methods are public make the class more flexible
or make it easier to add new functionality to the program?
AquaFish class currently has several public modifier
methods such as
Could either of them be private without affecting the rest of the program?
If so, would it be a good idea to make them private? Consider the
issues listed above.
- In the previous lab, you added two new methods,
descend, to the
Each method causes the
fish to move up or down by one y-coordinate value. Should the new
methods be public or private? Why?
- In the previous lab, you also added a new method
which encapsulates all of the moving behavior of a fish. Should this method be
public or private? Why?
Copyright Alyce Faulstich Brady, 2001.
Modified by Pamela Cutter, 2002.