Browse Source

Added second test case to shoot(): Call on Coordinate without ship

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

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

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

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

@ -60,7 +60,8 @@ class CoordinateTest {
} }
static Stream<Arguments> ShootFunctionFieldStates() { static Stream<Arguments> ShootFunctionFieldStates() {
return Stream.of(Arguments.of("Field State is HIT", new Coordinate(0, 0), Coordinate.HIT));
return Stream.of(Arguments.of("Field State is HIT", new Coordinate(0, 0), Coordinate.HIT),
Arguments.of("Field State is SHOT", new Coordinate(0, 1), Coordinate.SHOT));
} }
} }
Loading…
Cancel
Save