|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
java.lang.Object | +--reversi.TextGameBoard
A class to handle all actions related to the Reversi Game Board. It provides useful methods for the Game Controller to call. @see ReversiGame
| Fields inherited from interface reversi.GameBoard |
EMPTY, GREEN, RED |
| Constructor Summary | |
TextGameBoard()
Constructor needs the specific Canvas to call its drawing methods. |
|
| Method Summary | |
boolean |
checkMove(int player,
Coordinates c)
This method checks whether a given move would be valid. |
int |
countStones(int player)
Counts the number of pieces for the given player. |
int |
getPosition(Coordinates c)
This method gives access to the player to find out the status of the game board. |
protected int |
getPosition(int x,
int y)
Same as other, but with x and y instead. |
int |
getSize()
Method implementing the interface @see GameBoard. |
boolean |
isFull()
Checks whether the board is already full. |
boolean |
isMoveAvailable(int player)
This method returns true if there is at least one possible move for player and false if he has to pass. |
void |
makeMove(int player,
Coordinates c)
This method sets the piece for the given player and updates the board by flipping all possible of the opponent's pieces. |
java.lang.String |
toString()
|
void |
updateBoard(GameBoard gb)
Clone the situation of the board. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public TextGameBoard()
c - An instance of @see ReversiCanvas.| Method Detail |
public int getSize()
getSize in interface GameBoardpublic void updateBoard(GameBoard gb)
public int getPosition(Coordinates c)
throws OutOfBoundsException
getPosition in interface GameBoardc - The Coordinates for the board. -
protected int getPosition(int x,
int y)
public boolean isMoveAvailable(int player)
player - Specifies the color of the player,
either GameBoard.RED or GameBoard.GREEN.
public boolean checkMove(int player,
Coordinates c)
player - The player, either GameBoard.RED or
GameBoard.GREEN.c - The Coordinates to be checked.
public void makeMove(int player,
Coordinates c)
player - The player, either GameBoard.RED or
GameBoard.GREEN.c - The Coordinates where to put the
piece for the given player.public boolean isFull()
public int countStones(int player)
player - The color of the pieces for the player
to count, either GameBoard.RED or GameBoard.GREEN.public java.lang.String toString()
toString in class java.lang.Object
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||