src/demo/TicTacToe.java
private boolean checkWinner(Player player) {
            int diagonalStatistics = 0;
            int adiagonalStatistics = 0;
            GameSlotType gameSlotType = player.playerRole == PlayerRole.NOUGHT ? GameSlotType.NOUGHT : GameSlotType.CROSS;
            for (int row = 0; row < boardSize; row++) {
                int rowStat = 0;
                int colStat = 0;
                for (int col = 0; col < boardSize; col++) {
                    if (gameBoard[row][col] == gameSlotType) rowStat++; else rowStat = 0;
                    if (gameBoard[col][row] == gameSlotType) colStat++; else colStat = 0;
                }
                if (rowStat == boardSize || colStat == boardSize) return true;

                if (gameBoard[row][row] == gameSlotType) diagonalStatistics++; else diagonalStatistics = 0;
                if (gameBoard[row][boardSize - 1 - row] == gameSlotType) adiagonalStatistics++; else adiagonalStatistics = 0;
            }

            return diagonalStatistics == boardSize || adiagonalStatistics == boardSize;
        }
/**
         * Checks if player has won the game.
         *
         * @param player current player.
         * @return return player if player has won otherwise returns false.
         */
Checks if player has won the game.
@param player current player.
@return return player if player has won otherwise returns false.
Checks if player has won the game . @param player current player . @return return player if player has won otherwise returns false .
private boolean checkWinner(Player player) {
            int diagonalStatistics = 0;
            int adiagonalStatistics = 0;
            GameSlotType gameSlotType = player.playerRole == PlayerRole.NOUGHT ? GameSlotType.NOUGHT : GameSlotType.CROSS;
            for (int row = 0; row < boardSize; row++) {
                int rowStat = 0;
                int colStat = 0;
                for (int col = 0; col < boardSize; col++) {
                    if (gameBoard[row][col] == gameSlotType) rowStat++; else rowStat = 0;
                    if (gameBoard[col][row] == gameSlotType) colStat++; else colStat = 0;
                }
                if (rowStat == boardSize || colStat == boardSize) return true;
                if (gameBoard[row][row] == gameSlotType) diagonalStatistics++; else diagonalStatistics = 0;
                if (gameBoard[row][boardSize - 1 - row] == gameSlotType) adiagonalStatistics++; else adiagonalStatistics = 0;
            }
            return diagonalStatistics == boardSize || adiagonalStatistics == boardSize;
        }
private boolean checkWinner ( Player player ) { int diagonalStatistics = 0 ; int adiagonalStatistics = 0 ; GameSlotType gameSlotType = player . playerRole == PlayerRole . NOUGHT ? GameSlotType . NOUGHT : GameSlotType . CROSS ; for ( int row = 0 ; row < boardSize ; row ++ ) { int rowStat = 0 ; int colStat = 0 ; for ( int col = 0 ; col < boardSize ; col ++ ) { if ( gameBoard [ row ] [ col ] == gameSlotType ) rowStat ++ ; else rowStat = 0 ; if ( gameBoard [ col ] [ row ] == gameSlotType ) colStat ++ ; else colStat = 0 ; } if ( rowStat == boardSize || colStat == boardSize ) return true ; if ( gameBoard [ row ] [ row ] == gameSlotType ) diagonalStatistics ++ ; else diagonalStatistics = 0 ; if ( gameBoard [ row ] [ boardSize - 1 - row ] == gameSlotType ) adiagonalStatistics ++ ; else adiagonalStatistics = 0 ; } return diagonalStatistics == boardSize || adiagonalStatistics == boardSize ; }
Checks if player has won the game.
Checks if player has won the game .