public abstract class AbstractGrid<E> extends java.lang.Object implements Grid<E>
AbstractGrid
contains the methods that are common to grid
implementations. Constructor and Description |
---|
AbstractGrid() |
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<Location> |
getEmptyAdjacentLocations(Location loc)
Gets the valid empty locations adjacent to a given location in all eight
compass directions (north, northeast, east, southeast, south, southwest,
west, and northwest).
|
java.util.ArrayList<E> |
getNeighbors(Location loc)
Gets the neighboring occupants in all eight compass directions (north,
northeast, east, southeast, south, southwest, west, and northwest).
|
java.util.ArrayList<Location> |
getOccupiedAdjacentLocations(Location loc)
Gets the valid occupied locations adjacent to a given location in all
eight compass directions (north, northeast, east, southeast, south,
southwest, west, and northwest).
|
java.util.ArrayList<Location> |
getValidAdjacentLocations(Location loc)
Gets the valid locations adjacent to a given location in all eight
compass directions (north, northeast, east, southeast, south, southwest,
west, and northwest).
|
java.lang.String |
toString()
Creates a string that describes this grid.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
get, getNumCols, getNumRows, getOccupiedLocations, isValid, put, remove
public java.util.ArrayList<E> getNeighbors(Location loc)
Grid
loc
is valid in this gridgetNeighbors
in interface Grid<E>
loc
- a location in this gridloc
in this gridpublic java.util.ArrayList<Location> getValidAdjacentLocations(Location loc)
Grid
loc
is valid in this gridgetValidAdjacentLocations
in interface Grid<E>
loc
- a location in this gridloc
in this gridpublic java.util.ArrayList<Location> getEmptyAdjacentLocations(Location loc)
Grid
loc
is valid in this gridgetEmptyAdjacentLocations
in interface Grid<E>
loc
- a location in this gridloc
in this gridpublic java.util.ArrayList<Location> getOccupiedAdjacentLocations(Location loc)
Grid
loc
is valid in this gridgetOccupiedAdjacentLocations
in interface Grid<E>
loc
- a location in this gridloc
in this gridpublic java.lang.String toString()
toString
in class java.lang.Object