Class FastMover

java.lang.Object
  |
  +--Animal
        |
        +--MovingAnimal
              |
              +--FastMover
Direct Known Subclasses:
Crab, Shrimp, Starfish

public abstract class FastMover
extends MovingAnimal
implements ReproducesbyEggs

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


Method Summary
abstract  FastMover getNewFastMover()
          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
 Set laysEggs()
          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.
 Location makeMove(Location myLoc, World myWorld)
          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.
 
Methods inherited from class MovingAnimal
getDirection, getSpeed, setSpeed
 
Methods inherited from class Animal
getAge, getmaxAge, getPrintChar, incrAge, setmaxAge, timeToDie
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getNewFastMover

public abstract FastMover getNewFastMover()
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
Returns:
FastMover reference to a new object of a descendent class

makeMove

public Location makeMove(Location myLoc,
                         World myWorld)
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. if not, a new direction is tried; if so, then that Location is returned
Overrides:
makeMove in class Animal
Returns:
a free Location to which the animal should move

laysEggs

public Set laysEggs()
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.
Specified by:
laysEggs in interface ReproducesbyEggs
Returns:
Set of fast moving animals of one descendent class; an empty Set indicates no survivors