From 2d40913c30e4e3283a611447c174184e65b10546 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Mon, 17 Jan 2022 17:33:43 +0100 Subject: [PATCH] 4gewinnt: added setter for currentPlayer --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 4 ++++ src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 06ee5f3..81b03cb 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -24,6 +24,10 @@ public class Logic { return board[row][column]; } + public void setCurrentPlayer(int player) { + currentPlayer = player; + } + public int playChip(int[][] playfield, int column, int player) { //add board update diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index 0dd727b..53d2061 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -111,6 +111,15 @@ class LogicTest { assertEquals(player, realResult); } + @Test + void setCurrentPlayerTest() { + int player = 1; + + testObj.setCurrentPlayer(player); + + assertEquals(player, testObj.currentPlayer); + } + private static Stream playfieldResults() { int[][] playfield1 = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0},