Marine Biology Simulation
The marine biologists decided that they would also like faster-moving fish in the simulation. In particular, the biologists decided that:
~ X ~ N ~ ~ F ~ ~ X N F ~ ~ ~ ~ ~ ~
The key to the movement of fast fish is the way they choose the empty neighboring
locations to which they could move. Fast fish move within a wider neighborhood
than just their immediately adjacent neighbors. You may want to create a new
findMoveLocs, that would find the possible move locations
in the wider neighborhood, and then redefine the
findMoveLocs rather than calling
As you design your implementation of the fast fish subclass, be sure to consider fast fish in different locations and with neighbors in different locations, as in the two examples above or the example below. For each configuration, identify the locations to which the fast fish might move. Then develop test cases and expected results to test your new fast fish subclass.
F ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
You might want to make all fast fish one color (such as cyan) to help them
show up as you run the simulation, just as Pat did for darters and slow fish.
Then develop an initial configuration file that contains fast fish (or a mixture
of fast fish and your other
Fish subclasses). Test your new
subclass using the test cases you developed earlier.
Sometimes when adding functionality to a program, you realize that you could have designed it differently in the first place in a way that would make it easier to modify now. You might even decide that it's worth going back and changing the original before making your new changes. This is called refactoring.
Fish class to break up the
method and create a
findMoveLocs method there. Which pieces of
nextLocation method in
Fish should stay
nextLocation and which should move to
If you design this correctly, neither
will have to change at all, and your new fast fish subclass will only have to