diff --git a/src/main/java/de/tims/fleetstorm/ai/Logic.java b/src/main/java/de/tims/fleetstorm/ai/Logic.java index ca0e69e..e6547ee 100644 --- a/src/main/java/de/tims/fleetstorm/ai/Logic.java +++ b/src/main/java/de/tims/fleetstorm/ai/Logic.java @@ -8,6 +8,7 @@ import de.tims.fleetstorm.matchfield.Matchfield; public class Logic { + private Matchfield matchfield; private Coordinate lastShot; public Coordinate chooseField(Matchfield matchfield) { @@ -46,4 +47,13 @@ public class Logic { return lastShot; } + public void setMatchfield(Matchfield matchfield) { + this.matchfield = matchfield; + + } + + public Matchfield getMatchfield() { + return matchfield; + } + } diff --git a/src/test/java/de/tims/fleetstorm/ai/LogicTest.java b/src/test/java/de/tims/fleetstorm/ai/LogicTest.java index dd4f8c3..8fafc91 100644 --- a/src/test/java/de/tims/fleetstorm/ai/LogicTest.java +++ b/src/test/java/de/tims/fleetstorm/ai/LogicTest.java @@ -83,4 +83,20 @@ class LogicTest { } + @Test + void testSetMatchfield() { + Logic logic = new Logic(); + Matchfield matchfield; + int size = 4; + matchfield = new Matchfield(size); + matchfield.createMatchfield(); + + Matchfield result = logic.getMatchfield(); + assertEquals(result, null); + logic.setMatchfield(matchfield); + result = logic.getMatchfield(); + assertNotNull(result); + + } + }