diff --git a/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java b/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java index 1716226..5dac96f 100644 --- a/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java +++ b/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]; } diff --git a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java index d4c5f3a..c829a9d 100644 --- a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java +++ b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java @@ -74,6 +74,9 @@ class MatchfieldCreationTest { static Stream 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)); } }