public class TicTacToe { TicTacToe() { board = new char [3] [3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { board[i][j] = EMPTY; } } turn = X; } public char getTurn () { return turn; } public boolean isEmpty (int x, int y) { return (board[x][y] == EMPTY); } public String getPlay (int x, int y) { char result = board[x][y]; return Character.toString(result); } public void makeGuess (int x, int y) { if (board[x][y] == EMPTY) { board[x][y] = turn; turn = otherTurn (turn); } } private char otherTurn (char turn) { if (turn == X) { return O; } else { return X; } } private char [] [] board; private char turn; private static final int EMPTY = 'e'; private static final int X = 'X'; private static final int O = 'O'; }