Browse Source

Added test case when field was already hitted

Lorenz Hohmann 3 years ago
parent
commit
ae72cce719
  1. 2
      src/main/java/de/tims/fleetstorm/matchfield/Coordinate.java
  2. 3
      src/test/java/de/tims/fleetstorm/matchfield/CoordinateTest.java

2
src/main/java/de/tims/fleetstorm/matchfield/Coordinate.java

@ -45,7 +45,7 @@ public class Coordinate {
}
public boolean shoot() {
if (this.state == Coordinate.SHOT)
if (this.state == Coordinate.SHOT || this.state == Coordinate.HIT)
return false;
if (this.state == Coordinate.SHIP) {

3
src/test/java/de/tims/fleetstorm/matchfield/CoordinateTest.java

@ -76,6 +76,9 @@ class CoordinateTest {
assertTrue(matchfield.getField(0, 0).shoot());
assertFalse(matchfield.getField(0, 0).shoot());
matchfield.getField(3, 4).shoot();
assertFalse(matchfield.getField(3, 4).shoot());
}
}
Loading…
Cancel
Save