Class Animal

java.lang.Object
  |
  +--Animal
Direct Known Subclasses:
MovingAnimal, Sessile

public abstract class Animal
extends java.lang.Object

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 Summary
 int getAge()
          observer of animal's age
 int getmaxAge()
          observer of animal's maximum age; can be called by simulation clients
abstract  char getPrintChar()
          function returns printable character representation of animal
 void incrAge()
          mutator of animal's age; can be called by simulation clients
abstract  Location makeMove(Location l, World w)
          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;
protected  void setmaxAge(int age)
          mutator of animal's maximum age; called by descendent classes
 boolean timeToDie()
          function calculates whether or not the animal attains its maximum age on this time step; if so then it dies; if not it survives
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getAge

public int getAge()
observer of animal's age
Returns:
int age of Animal

incrAge

public void incrAge()
mutator of animal's age; can be called by simulation clients
Returns:
int age of animal

setmaxAge

protected void setmaxAge(int age)
mutator of animal's maximum age; called by descendent classes

getmaxAge

public int getmaxAge()
observer of animal's maximum age; can be called by simulation clients
Returns:
int maximum age of animal

timeToDie

public boolean timeToDie()
function calculates whether or not the animal attains its maximum age on this time step; if so then it dies; if not it survives
Returns:
true if animal dies on this time step, otherwise false

getPrintChar

public abstract char getPrintChar()
function returns printable character representation of animal
Returns:
char print character for animal

makeMove

public abstract Location makeMove(Location l,
                                  World w)
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;
Returns:
Location for move