|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ants.Critter
public abstract class Critter
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 |
---|
public Critter(AntWorld world, int row, int col)
world
- - a reference to the AntWorld where the Critter livesrow
- - the row coordinate of the cell in which the Critter livescol
- - the column coordinate of the cell in which the Critter livespublic Critter(Critter critter)
critter
- - the Critter to copyMethod Detail |
---|
protected Critter clone()
clone
in class java.lang.Object
public abstract boolean breed()
public abstract int move()
public abstract boolean starve()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |