public class Board
extends java.lang.Object
Constructor and Description |
---|
Board(int size)
Constructs an empty size-by-size board.
|
Modifier and Type | Method and Description |
---|---|
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.
|
public Board(int size)
size
- the size of the board.java.lang.IllegalArgumentException
- if size is less than 1.public boolean safe(int row, int col)
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()