diff --git a/src/main/java/de/tims/tictactoe/GameLogic.java b/src/main/java/de/tims/tictactoe/GameLogic.java index d9a59ab..2a71983 100644 --- a/src/main/java/de/tims/tictactoe/GameLogic.java +++ b/src/main/java/de/tims/tictactoe/GameLogic.java @@ -48,14 +48,14 @@ public class GameLogic { // check columns for (int i = 0; i < this.board.length; i++) { for (int j = 0; j < this.board[0].length; j++) { - if(board[i][j] == player) countFields++; + if(board[i][j] == player) countFields++; } } if(countFields == this.board.length) finished = true; // check rows - for (int i = 0; i < this.board.length; i++) { - for (int j = 0; j < this.board[0].length; j++) { + for (int i = 0; i < this.board[0].length; i++) { + for (int j = 0; j < this.board.length; j++) { if(board[j][i] == player) countFields++; } } diff --git a/src/test/java/de/tims/tictactoe/GameLogicTest.java b/src/test/java/de/tims/tictactoe/GameLogicTest.java index e22d0de..e2ec822 100644 --- a/src/test/java/de/tims/tictactoe/GameLogicTest.java +++ b/src/test/java/de/tims/tictactoe/GameLogicTest.java @@ -138,6 +138,10 @@ class GameLogicTest { {{'x', '-', '-'}, {'x', '-', '-'}, {'x', '-', '-'}}), + Arguments.of("check win in column 1 for player 1", 'x', true, new char[][] + {{'-', 'x', '-'}, + {'-', 'x', '-'}, + {'-', 'x', '-'}}), Arguments.of("check win in column 0 for player 2", 'o', true, new char[][] {{'o', '-', '-'}, {'o', '-', '-'},