public class BlockGrid extends Object
n-by-n where n >= 1. Each grid
location is accessed using integer indices for the row and column (where the
indices are zero based). The following image shows a 3-by-
3 grid with its indices:
Each grid location is either set (true) or clear (
false). Use the set method to set a grid position.
Use the clear method to clear a grid position. The following
image shows the S-block shape where the green grid positions are set and the
white grid positions are clear.

| Constructor and Description |
|---|
BlockGrid(int n)
Create a grid of size
n-by-n. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear(int row,
int col)
Clears a grid location.
|
void |
clearAll()
Clears all of the grid locations.
|
boolean |
get(int row,
int col)
Gets the state of a grid location using zero-based row and column indices.
|
void |
set(int row,
int col)
Sets a grid location.
|
int |
size()
Get the grid size.
|
public BlockGrid(int n)
n-by-n. All of the grid
positions are set to false.IllegalArgumentException - if n < 1n - the size of the gridpublic final void clearAll()
public int size()
public boolean get(int row,
int col)
IndexOutOfBoundsException - if row < 0, row >= size(),
col < 0, or col >= size()row - the row index of the desired grid locationcol - the column index of the desired grid locationtrue if the grid location is set, false
otherwisepublic void set(int row,
int col)
IndexOutOfBoundsException - if row < 0, row >= size(),
col < 0, or col >= size()row - the row index of the desired grid locationcol - the column index of the desired grid locationpublic void clear(int row,
int col)
IndexOutOfBoundsException - if row < 0, row >= size(),
col < 0, or col >= size()row - the row index of the desired grid locationcol - the column index of the desired grid location