|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectexamples.tictactoe.TicTacToeBoard
A class representing a simple 2-dimensional TicTacToe board. Includes methods to set valid moves and determine who (if anyone) has won the game.
| Field Summary | |
private int[][] |
board_
Double-subscripted array storing the board. |
| Constructor Summary | |
TicTacToeBoard()
Default constructor. |
|
| Method Summary | |
int |
getMove(int position)
Gets the number of the move. |
int |
getMove(int x,
int y)
Gets the number of the move. |
boolean |
hasEnded()
Returns true if all fields are set |
boolean |
isEmpty()
|
boolean |
setMove(int position,
int move)
Simple method of setting a move. |
boolean |
setMove(int y,
int x,
int move)
Complex, coordinate-based, method of setting a move. |
String |
toString()
Generates a string representing the current state of the gameboard. |
int |
whoWon()
Determines which player (if any) has won. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
private int[][] board_
| Constructor Detail |
public TicTacToeBoard()
| Method Detail |
public boolean setMove(int position,
int move)
position - Spot on the TicTacToe board to be filled.move - Symbol to be placed on the position
(either 1 or 2)
public boolean setMove(int y,
int x,
int move)
y - The row to place the symbol in.x - The column to place the symbol in.move - The symbol to be placed on that position
(either 1 or 2).
public int getMove(int x,
int y)
public int getMove(int position)
public boolean isEmpty()
public boolean hasEnded()
public int whoWon()
public String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||