Browse Source

Added test case when field was already hitted

fleetstorm
Lorenz Hohmann 3 years ago
parent
commit
cc34afa847
  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() { public boolean shoot() {
if (this.state == Coordinate.SHOT)
if (this.state == Coordinate.SHOT || this.state == Coordinate.HIT)
return false; return false;
if (this.state == Coordinate.SHIP) { 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()); assertTrue(matchfield.getField(0, 0).shoot());
assertFalse(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