|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.epochx.ant.Ant
public class Ant
An Ant represents an artificial ant which exists within and can move about
and perform other actions on an AntLandscape.
| Constructor Summary | |
|---|---|
Ant(int timeSteps,
AntLandscape landscape)
Constructs an Ant object on the given landscape. |
|
| Method Summary | |
|---|---|
void |
eatFood()
Increments the number of food pellets the ant has eaten. |
int |
getFoodEaten()
Returns the number of food pellets the ant has eaten. |
java.awt.Point |
getLocation()
Returns the current location of Ant as a point in the x/y-coordinate system that represents the landscape. |
int |
getMaxMoves()
Returns the maximum number of time steps the ant is allowed to move. |
int |
getMoves()
Gets the number of time steps the ant has completed. |
Orientation |
getOrientation()
Returns the direction the Ant is currently facing and travelling. |
boolean |
isFoodAhead()
Tests whether the next location for the ant, in its current orientation on its current landscape, contains a food pellet or not. |
void |
move()
Moves the ant's position one place in the direction it is currently facing based upon its orientation. |
void |
reset()
Reset the ant using the same number of time steps and on the same AntLandscape. |
void |
reset(int timeSteps,
AntLandscape landscape)
Resets the ant, setting it up with a new number of time steps allocated and a new AntLandscape. |
void |
setLocation(int x,
int y)
Sets the location of the ant on its landscape using an x/y co-ordinate system. |
void |
setOrientation(Orientation orientation)
Sets the orientation the Ant is to facing. |
void |
skip()
Skipping will cause the ant to fill one timestep without moving in its ant landscape. |
java.lang.String |
toString()
|
void |
turnLeft()
Turn the ant to the left relative to its current orientation. |
void |
turnRight()
Turn the ant to the right relative to its current orientation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public Ant(int timeSteps,
AntLandscape landscape)
timeSteps - the maximum number of time steps the ant is allowed to
move. Turning, moving and skipping all count as one time step.landscape - the landscape the ant will move through.| Method Detail |
|---|
public void reset(int timeSteps,
AntLandscape landscape)
AntLandscape.
timeSteps - the maximum number of time steps the ant is allowed to
move. Turning, moving and skipping all count as one time step.landscape - the landscape the ant will move through.public void reset()
AntLandscape.
public void turnLeft()
public void turnRight()
public void move()
public void eatFood()
public java.awt.Point getLocation()
Point.
public void setLocation(int x,
int y)
x - the x axis location of the ant.y - the Y axis location of the ant.public int getMoves()
public int getFoodEaten()
public Orientation getOrientation()
public void setOrientation(Orientation orientation)
orientation - The new orientation the ant is to face.public boolean isFoodAhead()
public void skip()
public int getMaxMoves()
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||