From cdf4b5b14da17c6ea271fcd8279386846fa39c8b Mon Sep 17 00:00:00 2001 From: Max Wenzel Date: Fri, 14 Jan 2022 12:09:47 +0100 Subject: [PATCH] Refactoring: cleared-booleans are private now (add getters for Test) --- .../java/de/tims/fleetstorm/ai/Logic.java | 24 +++++++++++++++---- .../java/de/tims/fleetstorm/ai/LogicTest.java | 8 +++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/main/java/de/tims/fleetstorm/ai/Logic.java b/src/main/java/de/tims/fleetstorm/ai/Logic.java index 6a93698..2c198d4 100644 --- a/src/main/java/de/tims/fleetstorm/ai/Logic.java +++ b/src/main/java/de/tims/fleetstorm/ai/Logic.java @@ -12,10 +12,10 @@ public class Logic { private Coordinate lastShot; public Coordinate target; private boolean foundShip = false; - public boolean clearedAbove = false; - public boolean clearedBelow = false; - public boolean clearedRight = false; - public boolean clearedLeft = false; + private boolean clearedAbove = false; + private boolean clearedBelow = false; + private boolean clearedRight = false; + private boolean clearedLeft = false; public Coordinate chooseField() { ArrayList possibleFields = new ArrayList(); @@ -124,4 +124,20 @@ public class Logic { } } + + public boolean getClearedAbove() { + return this.clearedAbove; + } + + public boolean getClearedBelow() { + return this.clearedBelow; + } + + public boolean getClearedRight() { + return this.clearedRight; + } + + public boolean getClearedLeft() { + return this.clearedLeft; + } } diff --git a/src/test/java/de/tims/fleetstorm/ai/LogicTest.java b/src/test/java/de/tims/fleetstorm/ai/LogicTest.java index 622eebb..dbce6ea 100644 --- a/src/test/java/de/tims/fleetstorm/ai/LogicTest.java +++ b/src/test/java/de/tims/fleetstorm/ai/LogicTest.java @@ -138,7 +138,7 @@ class LogicTest { logic.clearAbove(shot); - assertEquals(logic.clearedAbove, true); + assertEquals(logic.getClearedAbove(), true); } @Test @@ -155,7 +155,7 @@ class LogicTest { logic.clearBelow(shot); - assertEquals(logic.clearedBelow, true); + assertEquals(logic.getClearedBelow(), true); } @Test @@ -172,7 +172,7 @@ class LogicTest { logic.clearRight(shot); - assertEquals(logic.clearedRight, true); + assertEquals(logic.getClearedRight(), true); } @Test @@ -189,6 +189,6 @@ class LogicTest { logic.clearLeft(shot); - assertEquals(logic.clearedLeft, true); + assertEquals(logic.getClearedLeft(), true); } }