|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ChessBoard
A class used to represent a chess board, used to solve the n-queens problem. Methods are provided to place queens on the board, make a copy of the board, and return a String representation of the board. All indexing into the board start at 0. That is for an 8x8 board, valid row or column numbers are 0 - 7.
Field Summary | |
static char |
BLOCKED
A char used to represent a square to which some queen can move |
static char |
FREE
A char representation of a free square |
static char |
QUEEN
A char representation of a square containing a queen |
Constructor Summary | |
ChessBoard(ChessBoard other)
Creates an exact duplicate of the given board. |
|
ChessBoard(int size)
Creates a new, intially empty board of the specified size |
Method Summary | |
java.lang.Object |
clone()
Returns an exact copy of this ChessBoard. |
boolean |
placeQueen(int row,
int column)
Places a queen at the specified board position, marking all squares the newly placed queen can attack with the BLOCKED constant. |
int |
size()
Returns the number of rows and columns of this ChessBoard |
java.lang.String |
toString()
Returns a String representation of this ChessBoard |
Methods inherited from class java.lang.Object |
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
public static final char FREE
public static final char QUEEN
public static final char BLOCKED
Constructor Detail |
public ChessBoard(int size)
size
- the number of rows and columns on this ChessBoardpublic ChessBoard(ChessBoard other)
other
- the board to be copiedMethod Detail |
public java.lang.Object clone()
public boolean placeQueen(int row, int column)
row
- the row number at which to place the queencolumn
- the column number at which to place the queenpublic java.lang.String toString()
public int size()
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |