|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectGameBoard
public abstract class GameBoard
This class manages the data necessary for a Game board. The class is abstract so different types of game boards can be implemented (ie. chess, othello, checkers)
| Field Summary | |
|---|---|
static int |
NOTHING
Used to specify cells that are not occupied by any player |
static int |
P1
Used to specify cells occupied by player 1 |
static int |
P2
Used to specify cells occupied by player 2 |
| Constructor Summary | |
|---|---|
GameBoard(int initRow,
int initCol)
Constructor for starting a game with an empty board of size [initRow][initCol]. |
|
| Method Summary | |
|---|---|
abstract void |
chooseCell(int row,
int col,
int player)
Method to allow a player to select a cell. |
int |
getCell(int irow,
int jcol)
Accessor method to return the value in a certain cell |
int |
getTurn()
Accessor method that provides the current players turn |
abstract int |
getWinner()
Determines who has won the game. |
abstract boolean |
isLegalMove(java.awt.Dimension testMove)
This method checks if the selected move is allowed by the current player |
abstract void |
resetBoard()
Method to reset the entire board, assigning all cells to have value of NOTHING. |
void |
skipTurn()
Method for skipping the current player's turn |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static int NOTHING
public static int P1
public static int P2
| Constructor Detail |
|---|
public GameBoard(int initRow,
int initCol)
initRow - - number of rows on the boardinitCol - - number of columns on the board| Method Detail |
|---|
public int getCell(int irow,
int jcol)
dim - - row/col of the chosen cell
public int getTurn()
public void skipTurn()
public abstract void resetBoard()
public abstract void chooseCell(int row,
int col,
int player)
dim - - row/col of the chosen cellpublic abstract boolean isLegalMove(java.awt.Dimension testMove)
testMove - - the row/column of the move being queried
public abstract int getWinner()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||