abstract class at root of shore animal hierarchy
provides functionality for animal ages and when they die
also defines abstract methods makeMove() and getPrintChar()
field int age - animal's age (private)
field int maxAge - maximun age this animal can attain (private)
method uses random number generator to select how many
offspring of short-lived sessile animal survive; current settings are
30% 0 survivors, 30% 1 survivor; 40% 2 survivors
This class provides encapsulation a neighborhood in the simulation
A neighborhood of a point is like a tic-tac-toe board with the point in
in the middle.
abstract class which sets the maximum age of all fast moving animals,
defines makeMove() and laysEggs() for all fast moving animals
currently Crab, Shrimp, Starfish
abstract method forces all actual animal descendent classes
of FastMover to define a method that returns a new animal of
their kind; allows laysEggs() to be inherited by all these classes
abstract method forces all actual animal descendent classes
of ShortLivedSessile to define a method that returns a new animal of
their kind; allows buds() to be inherited by all these classes
method uses random number generator to select how many
offspring of fast moving animal survive; current settings are
60% 0 survivors, 30% 1 survivor, 10$ 2 survivors.
method uses random number generator to select how many
offspring of long-lived sessile animal survive; current settings are
50% 0 survivors, 50% 1 survivor;
function returns new Location (position) to move to for an animal;
if there is nowhere legal to move, then the function returns null;
if an animal is sessile, then the function returns null;
method implements movement for all fast moving animals
first a direction is picked and then multiplied by the
scale factor (speed field) of this animal; this Location
is checked to see if it is free.
function provides a new Location to which the Seahorse object
can move; checks that it moves with the current
note: chose to try 8 randomly chosen directions
abstract class which stores a speed field for all moving animals,
defines mutator and observer for speed field,
defines getDirection() method for us in calculating makeMove()
in descendent classes including FastMover and Seahorse;
field int speed - stores speed of movement of an animal
This method simply iterates through all objects in the World and
calls processTimeStepForObject(obj,loc) on each object
Gui.main() calls this nextTimeStep function for each time step
in the simulation
This class provides ability to print S for Starfish objects,
creates new Starfish objects for reproduction, and initializes
speed field for Starfish objects
This class is the simulation object; Animal is the root class of
the dweller hierarchy provided by the user
worldGrid is the representation of the World object
there are worldSize*worldSize points in the World
current is the encoded direction of the ocean current
time is the current time step
kint sets the interval of steps on which reproduction is tried
timeStep is a static variable to keep track of number of
time steps so far in the World simulation.