com.collegeboard.gridworld.grid
Class AbstractGrid<E>
java.lang.Object
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>
AbstractGrid
public AbstractGrid()
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