|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--edu.kzoo.grid.ArrayListGrid.ArrayListGridRep
Internal representation for an ArrayList
-based
implementation of a Grid
class.
Constructor Summary | |
protected |
ArrayListGrid.ArrayListGridRep(Grid.ValidityChecker checker)
Constructs an empty ArrayListGridRep representation of a grid. |
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. |
protected int |
indexOf(Location loc)
Get the index of the object at the specified location. |
boolean |
isValid(Location loc)
Verifies whether a location is valid in this grid. |
int |
numObjects()
Returns the number of objects 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 |
protected ArrayListGrid.ArrayListGridRep(Grid.ValidityChecker checker)
checker
- an object that knows how to check the validity
of a location in a gridMethod Detail |
public boolean isValid(Location loc)
isValid
in interface Grid.InternalRepresentation
loc
- location to check
true
if loc
is valid;
false
otherwisepublic int numObjects()
numObjects
in interface Grid.InternalRepresentation
public GridObject[] allObjects()
allObjects
in interface Grid.InternalRepresentation
public GridObject objectAt(Location loc)
objectAt
in interface Grid.InternalRepresentation
loc
- 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.InternalRepresentation
obj
- the new object to be addedpublic void remove(GridObject obj)
obj
is in this grid; verified
by the Grid
object.)
remove
in interface Grid.InternalRepresentation
obj
- the object to be removedprotected int indexOf(Location loc)
loc
- the location in which to look
loc
if there is one; -1 otherwise
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |