FileDocCategorySizeDatePackage
ChessGame.javaAPI DocExample1681Sat Dec 02 19:43:52 GMT 2000jabadot

ChessGame

public class ChessGame extends Object
The logic for maintaining a game, two (human?) players. This class is independant of any view logic - keep it so!

Fields Summary
public static final char
NONE
public static final char
KW
public static final char
QW
public static final char
BW
public static final char
RW
public static final char
NW
public static final char
PW
public static final char
KB
public static final char
QB
public static final char
BB
public static final char
RB
public static final char
NB
public static final char
PB
protected User
white
protected User
black
ArrayList
moves
public static final short
WNEXT
public static final short
BNEXT
public short
nextMove
public char[]
board
Constructors Summary
public ChessGame()



	  
		moves = new ArrayList();
		initBoard();
	
Methods Summary
protected voidinitBoard()

		// white
		board[0][0] = RW;
		board[0][1] = KW;
		board[0][2] = BW;
		board[0][3] = QW;
		board[0][4] = KW;
		board[0][5] = BW;
		board[0][6] = KW;
		board[0][7] = RW;
		for (int i=0; i<8; i++)
			board[1][i] = PW;

		// vacant
		for (int r=2; r<=5; r++)
			for (int c=0; c<8; c++)
				board[r][c] = NONE;

		// black
		for (int i=0; i<8; i++)
			board[6][i] = PB;
		board[7][0] = RB;
		board[7][1] = KB;
		board[7][2] = BB;
		board[7][3] = QB;
		board[7][4] = KB;
		board[7][5] = BB;
		board[7][6] = KB;
		board[7][7] = RB;
	
public voidmove(java.lang.String move)
Accept a move in standard "kp4" notation