From 3364446cd68bdbdb59cfe4b8ec1775f6e989e610 Mon Sep 17 00:00:00 2001 From: Max Wenzel Date: Fri, 14 Jan 2022 13:49:40 +0100 Subject: [PATCH] add sinkShip --- .../java/de/tims/fleetstorm/ai/Logic.java | 8 +++++++- .../java/de/tims/fleetstorm/ai/LogicTest.java | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/tims/fleetstorm/ai/Logic.java b/src/main/java/de/tims/fleetstorm/ai/Logic.java index 11cbb85..d8b2e9b 100644 --- a/src/main/java/de/tims/fleetstorm/ai/Logic.java +++ b/src/main/java/de/tims/fleetstorm/ai/Logic.java @@ -149,7 +149,13 @@ public class Logic { } public void sinkShip() { - // TODO Auto-generated method stub + if (foundShip && clearedAbove && clearedBelow && clearedLeft && clearedRight) { + this.foundShip = false; + this.clearedAbove = false; + this.clearedBelow = false; + this.clearedLeft = false; + this.clearedRight = false; + } } diff --git a/src/test/java/de/tims/fleetstorm/ai/LogicTest.java b/src/test/java/de/tims/fleetstorm/ai/LogicTest.java index 3171cb2..5579585 100644 --- a/src/test/java/de/tims/fleetstorm/ai/LogicTest.java +++ b/src/test/java/de/tims/fleetstorm/ai/LogicTest.java @@ -236,4 +236,23 @@ class LogicTest { assertEquals(logic.getClearedLeft(), true); } + @Test + void testSinkShip() { + Logic logic = new Logic(); + + logic.setFoundShip(true); + logic.setClearedAbove(true); + logic.setClearedBelow(true); + logic.setClearedRight(true); + logic.setClearedLeft(true); + + logic.sinkShip(); + + assertEquals(logic.getFoundShip(), false); + assertEquals(logic.getClearedAbove(), false); + assertEquals(logic.getClearedBelow(), false); + assertEquals(logic.getClearedLeft(), false); + assertEquals(logic.getClearedRight(), false); + + } }