|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Board
Abstracts the common elements of the playing area of a game, such as Tic-Tac-Toe or Checkers. The board is "squashed" into a 1-dimensional array of integers, referenced as the board state. Positions containing friendly pieces have value 1, opponent pieces -1, and empty spaces 0.
Method Summary | |
---|---|
boolean |
checkForTie()
|
boolean |
checkForWin()
|
boolean |
checkLegalMove(int newMove)
|
java.lang.String |
displayBoard()
|
int |
getBoardSize()
|
int[] |
getBoardState()
|
void |
initializeBoard()
set up board to initial state before game has started |
void |
swap()
swap all friendly pieces for opponent and vice versa |
void |
updateBoard(int newMove)
updates board state such that position newMove will now equal 1 |
Method Detail |
---|
int getBoardSize()
void initializeBoard()
boolean checkLegalMove(int newMove)
newMove
- position in which to place next move
newMove
would create an invalid board state, true otherwisevoid updateBoard(int newMove)
newMove
will now equal 1
newMove
- position in which to place next move; must be between >= 0 and < size of boardboolean checkForWin()
boolean checkForTie()
java.lang.String displayBoard()
int[] getBoardState()
void swap()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |