java.lang.Objectgreenfoot.Actor
Wombat
public class Wombat
Wombat. A Wombat moves forward until it can't do so anymore, at which point it turns left. If a wombat finds a leaf, it eats it.
Constructor Summary | |
---|---|
Wombat()
|
Method Summary | |
---|---|
void |
act()
Do whatever the wombat likes to to just now. |
boolean |
canMove()
Test if we can move forward. |
void |
eatLeaf()
Eat a leaf. |
boolean |
foundLeaf()
Check whether there is a leaf in the same cell as we are. |
int |
getLeavesEaten()
Tell how many leaves we have eaten. |
void |
move()
Move one cell forward in the current direction. |
void |
setDirection(int direction)
Sets the direction we're facing. |
void |
turnLeft()
Turns towards the left. |
void |
turnRandom()
Turns towards the left. |
Methods inherited from class greenfoot.Actor |
---|
addedToWorld, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWorld, getX, getY, intersects, move, setImage, setImage, setLocation, setRotation, turn, turnTowards |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Wombat()
Method Detail |
---|
public void act()
act
in class greenfoot.Actor
public boolean canMove()
public void eatLeaf()
public boolean foundLeaf()
public int getLeavesEaten()
public void move()
public void setDirection(int direction)
public void turnLeft()
public void turnRandom()