|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectexamples.gp.paintedDesert.Ant
public class Ant
Represents the Ant. Contains the rules about how an Ant behaves.
| Constructor Summary | |
|---|---|
Ant(int x,
int y)
Constructs the Ant at an initial location. |
|
| Method Summary | |
|---|---|
int |
drop(AntMap antmap)
Drops the sand at the current location if possible. |
int |
getCarrying()
Returns the grain of sand the ant is carrying. |
int |
getMoves()
Identifies the number of moves the ant has performed |
int |
getPickedUpFromXLoc()
Returns the x location where the sand was picked up. |
int |
getPickedUpFromYLoc()
Returns the Y locaiton where the sand was picked up. |
int |
getXpos()
Returns the x location of the ant. |
int |
getYpos()
Returns the y location of the ant. |
int |
goE(AntMap map)
Instructs the ant to go east, if possible. |
int |
goN(AntMap map)
Instructs the ant to go north, if possible |
int |
goS(AntMap map)
Instructs the ant to go south, if possible |
int |
goW(AntMap map)
Instructs the ant to go west, if possible |
void |
incrementMoveCounter()
Increments the move counter for the ant |
boolean |
isCarrying()
Identifies if the ant is carrying any sand. |
boolean |
mayPickup(AntMap map)
Identifies whether the ant could pickup sand |
int |
moveRandom(AntMap map)
Randomly moves the ant. |
int |
pickup(AntMap antmap)
Picks up the sand at the current location, if the ant is not carrying any sand and there is sand at the location |
void |
reset()
Resets the ant to its original location on the map. |
boolean |
sandAtLocation(AntMap map)
Identifies whether there is sand at the location |
boolean |
sandBelongsHere(AntMap map)
Identifies that sand the ant is carrying, belongs in this column |
int |
sandColor(AntMap map)
Identifies the color of the sand at the ant's location |
void |
setPickedUpFromXLoc(int pickedUpFromXLoc)
Stores the x location where the sand was picked up. |
void |
setPickedUpFromYLoc(int pickedUpFromYLoc)
Sets the y location where the sand was picked up. |
void |
setXpos(int m_xpos)
Sets the x location of the ant. |
void |
setYpos(int m_ypos)
Sets the y location of the ant. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Ant(int x,
int y)
x - Initial x locationy - Initial y locaiton| Method Detail |
|---|
public void setXpos(int m_xpos)
m_xpos - public int getXpos()
public void setYpos(int m_ypos)
m_ypos - The y locationpublic int getYpos()
public int getCarrying()
public boolean isCarrying()
public void setPickedUpFromXLoc(int pickedUpFromXLoc)
public int getPickedUpFromXLoc()
public void setPickedUpFromYLoc(int pickedUpFromYLoc)
pickedUpFromYLoc - The y locationpublic int getPickedUpFromYLoc()
public int drop(AntMap antmap)
public int pickup(AntMap antmap)
antmap - The map of locations of sand
public int moveRandom(AntMap map)
map - The map of locations of sand
public int goE(AntMap map)
public int goW(AntMap map)
map -
public int goN(AntMap map)
map -
public int goS(AntMap map)
map -
public boolean mayPickup(AntMap map)
map -
public boolean sandAtLocation(AntMap map)
map -
public boolean sandBelongsHere(AntMap map)
map -
public int sandColor(AntMap map)
map -
public void incrementMoveCounter()
public int getMoves()
public void reset()
|
JGAP | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||