From e5abbc26f532406fd75c96e547e6c4b9dede1e06 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Sat, 15 Jan 2022 00:43:48 +0100 Subject: [PATCH] 4gewinnt: added getter for board --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 4 ++++ .../java/de/tims/viergewinnt/ai/LogicTest.java | 14 +++++++++++++- 2 files changed, 17 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 c26d4ee..06ee5f3 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -20,6 +20,10 @@ public class Logic { board[row][column] = player; } + public int getField(int row, int column) { + return board[row][column]; + } + 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 db2a1ce..0dd727b 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -96,7 +96,19 @@ class LogicTest { testObj.setField(player, row, column); - assertEquals(2, testObj.board[row][column]); + assertEquals(player, testObj.board[row][column]); + } + + @Test + void getFieldTest() { + int player = 2; + int row = 0; + int column = 0; + + testObj.setField(player, row, column); + int realResult = testObj.getField(row, column); + + assertEquals(player, realResult); } private static Stream playfieldResults() {