Browse Source

add getBelow() in Matchfield - case: nothingBelow

fleetstorm
Max Wenzel 3 years ago
committed by Lorenz Hohmann
parent
commit
66e3394f09
  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

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

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

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