public class TicTacToeModel extends GameModel
Modifier and Type | Class and Description |
---|---|
static interface |
TicTacToeModel.Listener |
static class |
TicTacToeModel.State
Type for the state of a square.
|
Modifier and Type | Field and Description |
---|---|
(package private) TicTacToeModel.State[][] |
board
The state of the board.
|
(package private) java.util.List<TicTacToeModel.Listener> |
listeners |
Constructor and Description |
---|
TicTacToeModel()
Creates a new tic-tac-toe game.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(TicTacToeModel.Listener listener) |
double |
get(int x,
int y)
Returns the value of the cell at the given coordinates.
|
TicTacToeModel.State |
getState(int x,
int y)
Returns the state of a given square.
|
boolean |
set(int x,
int y,
double value)
Sets the value of the cell at the given coordinates.
|
void |
setState(int x,
int y,
TicTacToeModel.State state)
Sets the state of the given square.
|
TicTacToeModel.State[][] board
java.util.List<TicTacToeModel.Listener> listeners
public TicTacToeModel.State getState(int x, int y)
x
- the horizontal position.y
- the vertical position.public void setState(int x, int y, TicTacToeModel.State state)
x
- the horizontal position.y
- the vertical position.state
- the state to set the square.public double get(int x, int y)
public boolean set(int x, int y, double value)
public void addListener(TicTacToeModel.Listener listener)