|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.collegeboard.gridworld.grid.BoundedGrid<E>
public class BoundedGrid<E>
| Constructor Summary | |
|---|---|
BoundedGrid(int rows,
int cols)
Constructs an empty BoundedGrid object with the given dimensions. |
|
| Method Summary | |
|---|---|
E |
get(Location loc)
Returns the object at a specific location in this grid |
ArrayList<Location> |
getOccupiedLocations()
Gets the locations in this grid that contain objects. |
boolean |
isValid(Location loc)
Checks whether a location is valid in this grid. |
int |
numCols()
Returns number of columns in this grid. |
int |
numRows()
Returns number of rows in this grid. |
E |
put(Location loc,
E obj)
Adds a new object to this grid. |
E |
remove(Location loc)
Removes an object from this grid. |
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 |
| Constructor Detail |
|---|
public BoundedGrid(int rows,
int cols)
rows > 0 and cols > 0.)
rows - number of rows in BoundedGridcols - number of columns in BoundedGrid| Method Detail |
|---|
public int numRows()
Grid
numRows in interface Grid<E>public int numCols()
Grid
numCols in interface Grid<E>public boolean isValid(Location loc)
Grid
isValid in interface Grid<E>loc - location to check (must not be null)
true if loc is valid in this grid;
false otherwisepublic ArrayList<Location> getOccupiedLocations()
Grid
getOccupiedLocations in interface Grid<E>public E get(Location loc)
Grid
get in interface Grid<E>loc - the location in which to look (must be valid)
loc;
null if loc is empty
public E put(Location loc,
E obj)
Grid
put in interface Grid<E>loc - the location at which to put the object (must be valid)obj - the new object to be added (must not be null)
public E remove(Location loc)
Grid
remove in interface Grid<E>loc - the location of the object that is to be removed (must be valid)
public String toString()
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||