diff --git a/src/main/java/de/tims/tictactoe/GameLogic.java b/src/main/java/de/tims/tictactoe/GameLogic.java index b60bf3d..7891235 100644 --- a/src/main/java/de/tims/tictactoe/GameLogic.java +++ b/src/main/java/de/tims/tictactoe/GameLogic.java @@ -47,12 +47,12 @@ public class GameLogic { // check columns for (int i = 0; i < this.board.length; i++) { - if(countFields == this.board.length) return finished = true; - countFields = 0; for (int j = 0; j < this.board[0].length; j++) { - if(board[j][i] == player) countFields++; + System.out.println(j + ", " + i); + if(board[j][i] == player) countFields++; } - + if(countFields == this.board.length) return finished = true; + countFields = 0; } countFields = 0; diff --git a/src/test/java/de/tims/tictactoe/GameLogicTest.java b/src/test/java/de/tims/tictactoe/GameLogicTest.java index 1210ed1..00914d4 100644 --- a/src/test/java/de/tims/tictactoe/GameLogicTest.java +++ b/src/test/java/de/tims/tictactoe/GameLogicTest.java @@ -177,7 +177,11 @@ class GameLogicTest { Arguments.of("check win in column 1 for player 2 with full board", 'o', true, new char[][] {{'x', 'o', 'o'}, {'x', 'o', 'x'}, - {'o', 'o', 'x'}}) + {'o', 'o', 'x'}}), + Arguments.of("check win in column 2 for player 2 with full board", 'o', true, new char[][] + {{'x', 'o', 'o'}, + {'x', 'x', 'o'}, + {'o', 'o', 'o'}}) ); }