Browse Source

add getAbove() in Matchfield - Case: nothingBelow

Max Wenzel 3 years ago
parent
commit
c3053c007f
  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

@ -48,7 +48,9 @@ public class Matchfield {
}
public Coordinate getBelow(Coordinate center) {
// TODO Auto-generated method stub
if (center.getX() == 0) {
return null;
}
return this.matchfield[center.getX() - 1][center.getY()];
}

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

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