From affdaad4b402076f3110fa9b9a440e9d1b9f320f Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Fri, 14 Jan 2022 20:54:00 +0100 Subject: [PATCH] 4gewinnt: finished setter for Board --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 2 +- src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 1378bed..c26d4ee 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -17,7 +17,7 @@ public class Logic { int currentPlayer; public void setField(int player, int row, int column) { - board[row][column] = 1; + board[row][column] = player; } public int playChip(int[][] playfield, int column, int player) { diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index 7a1c79e..db2a1ce 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -88,6 +88,17 @@ class LogicTest { assertEquals(1, testObj.board[row][column]); } + @Test + void setFieldPlayer2Test() { + int player = 2; + int row = 0; + int column = 0; + + testObj.setField(player, row, column); + + assertEquals(2, testObj.board[row][column]); + } + private static Stream playfieldResults() { int[][] playfield1 = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0},