All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class gpsys.cos.Terrain

java.lang.Object
   |
   +----gpsys.cos.Terrain

public class Terrain
extends Object
implements Serializable
The terrain consists of a torroidal grid of squares upon which the "grass grows". The terrain can be grown, and cut. In addition, an observer can be set which gets update messages each time the state of the terrain changes.

Author:
Emmanuel PIERRE
DEA IARFA,
See Also:
TerrainObserver

Variable Index

 o CS
 o csnrj
 o l0
 o L0
 o l1
 o L1
 o l2
 o L2
 o lmax
 o observed
True if the observer is wants to received state change information.
 o observer
A reference to an observer interested in monitoring the state of this terrain.
 o R1
 o R2
 o terrain
Used to hold the state of each square of the terrain.
 o ttl

Constructor Index

 o Terrain(int)
Create a square terrain of the specified dimension, with no observer.

Method Index

 o at(int, int, Robot)
Sets the specified square status, and informs the observer of the event.
 o disableObserver()
Disables the observer from receiving change messages.
 o enableObserver()
Enables the observer to receive change messages.
 o reinit()
Sets the all of the squares on the terrain to initial state.
 o setObserver(TerrainObserver)
Set the observer of the terrain to the specified observer.
 o updateTerrain()
Update terrain's lamp status.

Variables

 o terrain
 int terrain[][]
Used to hold the state of each square of the terrain.

 o l0
 int l0
 o l1
 int l1
 o l2
 int l2
 o ttl
 int ttl
 o csnrj
 int csnrj
 o lmax
 public static final int lmax
 o L0
 public static final int L0
 o L1
 public static final int L1
 o L2
 public static final int L2
 o R1
 public static final int R1
 o R2
 public static final int R2
 o CS
 public static final int CS
 o observed
 transient boolean observed
True if the observer is wants to received state change information.

 o observer
 transient TerrainObserver observer
A reference to an observer interested in monitoring the state of this terrain.

Constructors

 o Terrain
 public Terrain(int dimension)
Create a square terrain of the specified dimension, with no observer.

Parameters:
dimension - The value to be used for both the height and width of the terrain.

Methods

 o setObserver
 public void setObserver(TerrainObserver lo)
Set the observer of the terrain to the specified observer.

Parameters:
lo - The observer of the Terrain.
 o reinit
 public final void reinit()
Sets the all of the squares on the terrain to initial state. The observer is notified of this change.

 o at
 public final void at(int x,
                      int y,
                      Robot robot)
Sets the specified square status, and informs the observer of the event.

Parameters:
x - The X coordinate of the square to be cut.
y - The Y coordinate of the square to be cut.
 o enableObserver
 public void enableObserver()
Enables the observer to receive change messages.

 o disableObserver
 public void disableObserver()
Disables the observer from receiving change messages.

 o updateTerrain
 public void updateTerrain()
Update terrain's lamp status.


All Packages  Class Hierarchy  This Package  Previous  Next  Index