|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--edu.kzoo.grid.BoundedGrid.Array2DGridRep
The Array2DGridRep class represents an internal bounded
grid using a two-dimensional array.
| Constructor Summary | |
BoundedGrid.Array2DGridRep(int rows,
int cols)
Constructs an empty Array2DGridRep representation with the given dimensions. |
|
| Method Summary | |
void |
add(GridObject obj)
Adds a new object to this internal grid representation at the location it specifies. |
GridObject[] |
allObjects()
Returns all the objects in this grid. |
boolean |
isValid(Location loc)
Verifies whether a location is valid in this grid. |
int |
numCols()
Returns number of columns in this grid. |
int |
numObjects()
Returns the number of objects in this grid. |
int |
numRows()
Returns number of rows in this grid. |
GridObject |
objectAt(Location loc)
Returns the object at a specific location in this grid. |
void |
remove(GridObject obj)
Removes the object from this internal grid representation. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public BoundedGrid.Array2DGridRep(int rows,
int cols)
rows > 0 and cols > 0.)
rows - number of rows in the gridcols - number of columns in the grid| Method Detail |
public int numRows()
public int numCols()
public boolean isValid(Location loc)
isValid in interface Grid.InternalRepresentationloc - location to check
true if loc is valid;
false otherwisepublic int numObjects()
numObjects in interface Grid.InternalRepresentationpublic GridObject[] allObjects()
allObjects in interface Grid.InternalRepresentationpublic GridObject objectAt(Location loc)
objectAt in interface Grid.InternalRepresentationloc - the location in which to look
loc;
null if loc is not
in the grid or is emptypublic void add(GridObject obj)
obj.grid() is this grid and
obj.location() is a valid empty location;
verified by the Grid object.)
add in interface Grid.InternalRepresentationobj - the new object to be addedpublic void remove(GridObject obj)
obj is in this grid; verified
by the Grid object.)
remove in interface Grid.InternalRepresentationobj - the object to be removed
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||