From bc2e79b7a35656c26a08495ca77277a20ee58e13 Mon Sep 17 00:00:00 2001 From: Max Wenzel Date: Thu, 13 Jan 2022 13:30:35 +0100 Subject: [PATCH] add Matchfield variable with Getter/Setter in ai-logic --- src/main/java/de/tims/fleetstorm/ai/Logic.java | 10 ++++++++++ .../java/de/tims/fleetstorm/ai/LogicTest.java | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) 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); + + } + }