Browse Source

add getAbove() in Matchfield - Case: nothingAbove

fleetstorm
Max Wenzel 2 years ago
committed by Lorenz Hohmann
parent
commit
7c67747398
  1. 4
      src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java
  2. 6
      src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java

4
src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java

@ -56,7 +56,9 @@ public class Matchfield {
}
public Coordinate getAbove(Coordinate center) {
if (center.getY() == matchfield.length - 1) {
return null;
}
return matchfield[center.getX()][center.getY() + 1];
}

6
src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java

@ -106,7 +106,9 @@ class MatchfieldCreationTest {
static Stream<Arguments> getCoordinateAbove() {
Matchfield matchfield = new Matchfield(10);
return Stream.of(Arguments.of("above from (5/5) - should be (5,6)", matchfield, new Coordinate(5, 5),
matchfield.getField(5, 6)));
return Stream.of(
Arguments.of("above from (5/5) - should be (5,6)", matchfield, new Coordinate(5, 5),
matchfield.getField(5, 6)),
Arguments.of("above from (5/9) - should be null", matchfield, new Coordinate(5, 5), null));
}
}
Loading…
Cancel
Save