ants
Class Critter

java.lang.Object
  extended by ants.Critter

public abstract class Critter
extends java.lang.Object

Critter is an abstract class from which Ants and DoodleBugs are derived
Class Invariant: row and column are non-negative, world is not null

No new methods may be added to the Critter class

You will need other instance variables to
a. determine if it's time to breed
b. determine if the Critter has starved
c. manage Critter movement (you don't want to move the same Critter twice in the same simulation step)


Constructor Summary
Critter(AntWorld world, int row, int col)
          Construct a Critter that lives at the specified location in the AntWorld
Critter(Critter critter)
          Critter copy constructor
 
Method Summary
abstract  boolean breed()
          Determines if the Critter should breed
protected  Critter clone()
          A "dummy" clone method to make the compiler happy so that Ant and DoodleBug can override clone( ) as well Don't change this !!
abstract  int move()
          Determines the direction in which the Critter wishes to move
abstract  boolean starve()
          Determines whether the Critter has starved
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Critter

public Critter(AntWorld world,
               int row,
               int col)
Construct a Critter that lives at the specified location in the AntWorld

Parameters:
world - - a reference to the AntWorld where the Critter lives
row - - the row coordinate of the cell in which the Critter lives
col - - the column coordinate of the cell in which the Critter lives

Critter

public Critter(Critter critter)
Critter copy constructor

Parameters:
critter - - the Critter to copy
Method Detail

clone

protected Critter clone()
A "dummy" clone method to make the compiler happy so that Ant and DoodleBug can override clone( ) as well Don't change this !!

Overrides:
clone in class java.lang.Object

breed

public abstract boolean breed()
Determines if the Critter should breed

Returns:
true if the Critter wants to breed, otherwise returns false

move

public abstract int move()
Determines the direction in which the Critter wishes to move

Returns:
- the direction the Critter wants to move
One of AntWorld.NORTH, AntWorld.SOUTH, AntWorld.EAST, AntWorld.WEST

starve

public abstract boolean starve()
Determines whether the Critter has starved

Returns:
true if the Critter has starved, false otherwise