Browse Source

add sinkShip

Max Wenzel 3 years ago
parent
commit
f64d8a10f9
  1. 8
      src/main/java/de/tims/fleetstorm/ai/Logic.java
  2. 19
      src/test/java/de/tims/fleetstorm/ai/LogicTest.java

8
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;
}
}

19
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);
}
}
Loading…
Cancel
Save