diff --git a/src/main/java/de/tims/viergewinnt/ai/Logic.java b/src/main/java/de/tims/viergewinnt/ai/Logic.java index 2b7c862..a899c8a 100644 --- a/src/main/java/de/tims/viergewinnt/ai/Logic.java +++ b/src/main/java/de/tims/viergewinnt/ai/Logic.java @@ -31,7 +31,7 @@ public class Logic { } public void clearField() { - this.setField(0, 0, 0); + this.board = new int[getBoardSize()][getBoardSize()]; } public int getBoardSize() { diff --git a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java index ca8ca7f..51e149a 100644 --- a/src/test/java/de/tims/viergewinnt/ai/LogicTest.java +++ b/src/test/java/de/tims/viergewinnt/ai/LogicTest.java @@ -196,6 +196,15 @@ class LogicTest { assertEquals(0, testObj.getField(0, 0)); } + @Test + void clearFieldTestCompleteClear() { + testObj.setField(1, 5, 5); + + testObj.clearField(); + + assertEquals(0, testObj.getField(5, 5)); + } + @Test void getFreePlaceTestWithEmptyField() { assertEquals(testObj.getBoardSize() - 1, testObj.getFreePlace(0));