edu.kzoo.grid
Interface Grid.InternalRepresentation

All Known Implementing Classes:
ArrayListGrid.ArrayListGridRep, BoundedGrid.Array2DGridRep
Enclosing interface:
Grid

protected static interface Grid.InternalRepresentation

The InternalRepresentation interface specifies the methods that any internal representation of the Grid class must implement.


Method Summary
 void add(GridObject obj)
          Adds a new object to this environment 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 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 environment.
 

Method Detail

isValid

public boolean isValid(Location loc)
Verifies whether a location is valid in this grid.

Parameters:
loc - location to check
Returns:
true if loc is valid; false otherwise

numObjects

public int numObjects()
Returns the number of objects in this grid.

Returns:
the number of objects

allObjects

public GridObject[] allObjects()
Returns all the objects in this grid.

Returns:
an array of all the grid objects

objectAt

public GridObject objectAt(Location loc)
Returns the object at a specific location in this grid.

Parameters:
loc - the location in which to look
Returns:
the object at location loc; null if loc is not in the grid or is empty

add

public void add(GridObject obj)
Adds a new object to this environment at the location it specifies. (Precondition: obj.grid() is this grid and obj.location() is a valid empty location; verified by the Grid object.)

Parameters:
obj - the new object to be added

remove

public void remove(GridObject obj)
Removes the object from this environment. (Precondition: obj is in this environment; verified by the Grid object.)

Parameters:
obj - the object to be removed