From ddf26d199ad62093bf94d3e35b9c4d6986afeffa Mon Sep 17 00:00:00 2001 From: Malte Schellhardt Date: Tue, 18 Jan 2022 15:53:01 +0100 Subject: [PATCH] 4gewinnt: added constructor to create game logic --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 6 +++++- src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 9112de2..a208c96 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -18,7 +18,11 @@ public class Logic { private int player1Score = 0; private int player2Score = 0; - public void setField(int player, int row, int column) { + public Logic(int size) { + // TODO Auto-generated constructor stub + } + + public void setField(int player, int row, int column) { board[row][column] = player; } diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index b70ad80..cda8cbe 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -16,7 +16,7 @@ class LogicTest { @BeforeEach void setUp() throws Exception { - testObj = new Logic(); + testObj = new Logic(6); } @ParameterizedTest(name = "[{index}] {0} Player {2} {3}") @@ -160,6 +160,15 @@ class LogicTest { assertEquals(expectedResult, realResult); } + @Test + void createGameLogicTest() { + int size = 6; + Logic expectedResult = testObj; + Logic realResult = new Logic(size); + + assertEquals(expectedResult.getClass(), realResult.getClass()); + } + private static Stream playfieldResults() { int[][] playfield1 = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0},