From a7d3315ecbc7d7652e20a251d699cb7b70487f79 Mon Sep 17 00:00:00 2001 From: Steffen Helmke Date: Wed, 2 Feb 2022 14:44:17 +0100 Subject: [PATCH] 4gewinnt: finished clearField method --- src/main/java/de/tims/viergewinnt/ai/Logic.java | 2 +- src/test/java/de/tims/viergewinnt/ai/LogicTest.java | 9 +++++++++ 2 files changed, 10 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 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));