|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--gpsys.lawnmower.Lawn
The lawn consists of a torroidal grid of squares upon which the "grass grows". The lawn can be grown, and cut. In addition, an observer can be set which gets update messages each time the state of the lawn changes.
LawnObserver, Serialized Form| Field Summary | |
static int |
CUT
Used to tag squares on the lawn as having been cut. |
(package private) int |
cutCount
Used to keep a count of how many squares have been cut. |
(package private) int[][] |
lawn
Used to hold the state of each square of the lawn. |
(package private) boolean |
observed
True if the observer is wants to received state change information. |
(package private) LawnObserver |
observer
A reference to an observer interested in monitoring the state of this lawn. |
static int |
UNCUT
Used to tag squares as not having been cut. |
| Constructor Summary | |
Lawn(int dimension)
Create a square lawn of the specified dimension, with no observer. |
|
| Method Summary | |
void |
cut(int x,
int y)
Sets the specified square on the lawn to the CUT state, and informs the observer of the event. |
int |
cutCount()
Gets a count of the number of squares on the lawn in the CUT state. |
void |
disableObserver()
Disables the observer from receiving change messages. |
void |
enableObserver()
Enables the observer to receive change messages. |
void |
grow()
Sets the all of the squares on the lawn to UNCUT state (grown). |
void |
setObserver(LawnObserver lo)
Set the observer of the lawn to the specified observer. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
int[][] lawn
int cutCount
transient boolean observed
transient LawnObserver observer
public static final int CUT
public static final int UNCUT
| Constructor Detail |
public Lawn(int dimension)
dimension - The value to be used for both the height and width
of the lawn.| Method Detail |
public void setObserver(LawnObserver lo)
lo - The observer of the lawn.public final void grow()
public final void cut(int x,
int y)
x - The X coordinate of the square to be cut.y - The Y coordinate of the square to be cut.public final int cutCount()
public void enableObserver()
public void disableObserver()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||