| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectA4Shell.AbstractGrid<E>
A4Shell.BoundedGrid<E>
public class BoundedGrid<E>
A BoundedGrid is a rectangular grid with a finite number of
 rows and columns. 
 The implementation of this class is testable on the AP CS AB exam.
| Constructor Summary | |
|---|---|
BoundedGrid(int rows,
            int cols)
Constructs an empty bounded grid with the given dimensions.  | 
|
| Method Summary | |
|---|---|
 E | 
get(Location loc)
Returns the object at a given location in this grid.  | 
 int | 
getNumCols()
Returns the number of columns in this grid.  | 
 int | 
getNumRows()
Returns the number of rows in this grid.  | 
 java.util.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.  | 
 E | 
put(Location loc,
    E obj)
Puts an object at a given location in this grid.  | 
 E | 
remove(Location loc)
Removes the object at a given location from this grid.  | 
| Methods inherited from class A4Shell.AbstractGrid | 
|---|
getEmptyAdjacentLocations, getNeighbors, getOccupiedAdjacentLocations, getValidAdjacentLocations, toString | 
| Methods inherited from class java.lang.Object | 
|---|
equals, 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 getNumRows()
Grid
public int getNumCols()
Grid
public boolean isValid(Location loc)
Gridloc is not null
loc - the location to check
true if loc is valid in this grid,
 false otherwisepublic java.util.ArrayList<Location> getOccupiedLocations()
Grid
public E get(Location loc)
Gridloc is valid in this grid
loc - a location in this grid
loc (or null 
  if the location is unoccupied)
public E put(Location loc,
             E obj)
Gridloc is valid in this grid (2)
 obj is not null
loc - the location at which to put the objectobj - the new object to be added
loc (or null
 if the location was previously unoccupied)public E remove(Location loc)
Gridloc is valid in this grid
loc - the location of the object that is to be removed
null if the location
  is unoccupied)
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||