Class Wombat

java.lang.Object
  extended by greenfoot.Actor
      extended by Wombat

public class Wombat
extends greenfoot.Actor

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.

Version:
1.0
Author:
Michael Kolling

Field Summary
static int EAST
           
static int NORTH
           
static int SOUTH
           
static int WEST
           
 
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.
 
Methods inherited from class greenfoot.Actor
addedToWorld, getHeight, getImage, getIntersectingObjects, getNeighbours, getObjectsAtOffset, getObjectsInRange, getOneIntersectingObject, getOneObjectAtOffset, getRotation, getWidth, getWorld, getX, getY, intersects, setImage, setImage, setLocation, setRotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EAST

public static final int EAST
See Also:
Constant Field Values

NORTH

public static final int NORTH
See Also:
Constant Field Values

SOUTH

public static final int SOUTH
See Also:
Constant Field Values

WEST

public static final int WEST
See Also:
Constant Field Values
Constructor Detail

Wombat

public Wombat()
Method Detail

act

public void act()
Do whatever the wombat likes to to just now.

Overrides:
act in class greenfoot.Actor

canMove

public boolean canMove()
Test if we can move forward. Return true if we can, false otherwise.


eatLeaf

public void eatLeaf()
Eat a leaf.


foundLeaf

public boolean foundLeaf()
Check whether there is a leaf in the same cell as we are.


getLeavesEaten

public int getLeavesEaten()
Tell how many leaves we have eaten.


move

public void move()
Move one cell forward in the current direction.


setDirection

public void setDirection(int direction)
Sets the direction we're facing.


turnLeft

public void turnLeft()
Turns towards the left.