|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object Board
public class Board
Stores information relevant to solving the n queens problem of placing n queens on an n-by-y board.
Constructor Summary | |
---|---|
Board(int size)
Constructs an empty size-by-size board. |
Method Summary | |
---|---|
void |
place(int row,
int col)
Places a queen at position (row, col). |
void |
print()
Displays the current board to System.out. |
void |
remove(int row,
int col)
Removes the queen at position (row, col). |
boolean |
safe(int row,
int col)
Returns true if it is safe to place a queen at position (row, col). |
int |
size()
Returns the size of the board. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Board(int size)
size
- the size of the board.
java.lang.IllegalArgumentException
- if size is less than 1.Method Detail |
---|
public boolean safe(int row, int col)
row
- row of position to check.col
- column of position to check.
java.lang.IllegalArgumentException
- if row and col do not represent a
legal board position.public void place(int row, int col)
row
- row of position to check.col
- column of position to check.
java.lang.IllegalArgumentException
- if it is not safe to place a queen
at the given position.public void remove(int row, int col)
row
- row of position to check.col
- column of position to check.
java.lang.IllegalArgumentException
- if there is no queen at the given
position.public int size()
public void print()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |