Extending the Fish Class

After I had become familiar with the existing Marine Biology Simulation code, I talked to the marine biologists about what modifications or new features they wanted next. They wanted me to create several new kinds of fish with specialized patterns of movement to see what effect that would have on the simulation. Two that they were interested in to start were fish that dart quickly back and forth, and fish that move so slowly that they seem to move only occasionally.

First, Simple Subclass

To make sure I understood how to create a subclass, and how a subclass inherits from, and extends, its superclass, I decided to create the simplest possible Fish subclass, and then build up to the subclasses that the biologists were interested in.

Programming Exercise: Simplest Possible Subclass

Second, Simple Subclass

Programming Exercise: Whitefish

Extending a Class, Redefining Methods

Programming Exercise: Fish with Age

Programming Exercise: Aging Fish

It would be more realistic if the fish age over the course of the simulation.



Alyce Brady, Kalamazoo College