Browse Source

add sinkShip

fleetstorm
Max Wenzel 3 years ago
committed by Lorenz Hohmann
parent
commit
3364446cd6
  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