/** @see Board#makeMove(String, Move) */ @Override public boolean makeMove(String symbolString, Move move) { BoardSymbol symbol = BoardSymbol.valueOf(symbolString); int x = move.getX(); int y = move.getY(); // put the player's symbol at this move on the board board[x][y] = symbol; numberOfMoves++; int horizontalCount = 0; int verticalCount = 0; int forwardDiagonalCount = 0; int backwardDiagonalCount = 0; for (int i = 0; i < BOARD_SIZE; i++) { if (board[i][y] == symbol) { horizontalCount++; } if (board[x][i] == symbol) { verticalCount++; } if (board[i][i] == symbol) { forwardDiagonalCount++; } if (board[i][BOARD_SIZE - 1 - i] == symbol) { backwardDiagonalCount++; } } // if there are 3 of the same symbols in any of the possible winning directions, then we have a // winner if (horizontalCount == BOARD_SIZE || verticalCount == BOARD_SIZE || forwardDiagonalCount == BOARD_SIZE || backwardDiagonalCount == BOARD_SIZE) { return true; } else { return false; } }