From f03b32f0ddcbd512d322fe57c05696781d9654b7 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Mon, 17 Jan 2022 17:39:01 +0100 Subject: [PATCH] 4gewinnt: added getter for currentPlayer --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 4 ++++ src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 81b03cb..a6373d8 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -28,6 +28,10 @@ public class Logic { currentPlayer = player; } + public int getCurrentPlayer() { + return currentPlayer; + } + 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 53d2061..7546c0d 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -120,6 +120,16 @@ class LogicTest { assertEquals(player, testObj.currentPlayer); } + @Test + void getCurrentPlayerTest() { + int player = 2; + + testObj.setCurrentPlayer(player); + int realResult = testObj.getCurrentPlayer(); + + assertEquals(player, realResult); + } + private static Stream playfieldResults() { int[][] playfield1 = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0},