com.collegeboard.gridworld.grid
Class AbstractGrid<E>

java.lang.Object
  extended by com.collegeboard.gridworld.grid.AbstractGrid<E>
All Implemented Interfaces:
Grid<E>
Direct Known Subclasses:
BoundedGrid, UnboundedGrid

public abstract class AbstractGrid<E>
extends Object
implements Grid<E>


Constructor Summary
AbstractGrid()
           
 
Method Summary
 ArrayList<Location> getEmptyNeighborLocations(Location loc)
           
 ArrayList<E> getNeighbors(Location loc)
           
 ArrayList<Location> getOccupiedNeighborLocations(Location loc)
           
 ArrayList<Location> getValidNeighborLocations(Location loc)
          Gets the valid locations of the neighbors in all directions (north, northeast, east, southeast, south, southwest, west, and northwest)
 String toString()
          Creates a string representing all the objects in this grid (not necessarily in any particular order).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.collegeboard.gridworld.grid.Grid
get, getOccupiedLocations, isValid, numCols, numRows, put, remove
 

Constructor Detail

AbstractGrid

public AbstractGrid()
Method Detail

getValidNeighborLocations

public ArrayList<Location> getValidNeighborLocations(Location loc)
Gets the valid locations of the neighbors in all directions (north, northeast, east, southeast, south, southwest, west, and northwest)

Specified by:
getValidNeighborLocations in interface Grid<E>
Returns:
an array list of the valid locations of loc in all eight directions

getEmptyNeighborLocations

public ArrayList<Location> getEmptyNeighborLocations(Location loc)
Specified by:
getEmptyNeighborLocations in interface Grid<E>

getOccupiedNeighborLocations

public ArrayList<Location> getOccupiedNeighborLocations(Location loc)
Specified by:
getOccupiedNeighborLocations in interface Grid<E>

getNeighbors

public ArrayList<E> getNeighbors(Location loc)
Specified by:
getNeighbors in interface Grid<E>

toString

public String toString()
Creates a string representing all the objects in this grid (not necessarily in any particular order).

Overrides:
toString in class Object
Returns:
a string indicating all the objects in this environment