Browse Source

add getAbove() in Matchfield - Case: nothingAbove

Max Wenzel 3 years ago
parent
commit
6ea7194b5a
  1. 3
      src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java
  2. 5
      src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java

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

@ -41,6 +41,9 @@ public class Matchfield {
}
public Coordinate getField(int x, int y) {
if (x == 0) {
return null;
}
return matchfield[x][y];
}

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

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