|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--gpsys.lawnmower.Mower
The lawnmower itself is a robot that moves around on a lawn, cutting it. Unfortunately it only has a limited number of energy units available. These are divided into a number of left turns and number of movements. The lawnmower is only able to turn left when there are left turn units available, and similarly it can only move when there are movement units available. The lawnmower therefore stops when both of these units have run out. The lawn is mowed either by moving forward by one square thereby mowing that square or by leap frogging to any square and also mowing it.
| Field Summary | |
(package private) int |
direction
The current direction of the mower, can be one of NORTH, EAST, SOUTH or WEST. |
static int |
EAST
The value of direction when the mower is pointing EAST. |
(package private) Lawn |
lawn
The lawn to be mowed. |
(package private) int |
leftTurnsAvailable
The ration of left turn operations available. |
(package private) int |
movementAvailable
The ration of movement operations available. |
static int |
NORTH
The value of direction when the mower is pointing NORTH. |
static int |
SOUTH
The value of direction when the mower is pointing SOUTH. |
static int |
WEST
The value of direction when the mower is pointing WEST. |
(package private) int |
x
The X corrdinate of the mower on the lawn. |
(package private) int |
y
The Y corrdinate of the mower on the lawn. |
| Constructor Summary | |
Mower(Lawn lawn)
Construct a new mower to lawn the specified lawn. |
|
| Method Summary | |
Vector2Mod8 |
frog(Vector2Mod8 displacement)
Movement energy permitting, leap frogs the mower to by the specified (x,y) displacements. |
void |
left()
Turns the mower left if possible (if there are suffucient left turn units). |
void |
mow()
Movement energy permitting, moves the mower forward by one square in the current direction cutting the grass on that square. |
void |
reset()
Resets the mower state to default values (position = (4,4), direction = NORTH, leftTurnsAvailable = 100, movementAvailable = 100. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
Lawn lawn
int x
int y
int direction
int leftTurnsAvailable
int movementAvailable
public static final int NORTH
public static final int EAST
public static final int SOUTH
public static final int WEST
| Constructor Detail |
public Mower(Lawn lawn)
lawn - The lawn to be mowed.| Method Detail |
public void reset()
public final void left()
public final void mow()
public final Vector2Mod8 frog(Vector2Mod8 displacement)
displacement - The x and y displacements.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||