From bdb4c30cdb7b1e5d175b9ed2986c1acf7a418413 Mon Sep 17 00:00:00 2001 From: Max Wenzel Date: Wed, 12 Jan 2022 15:41:52 +0100 Subject: [PATCH] add getAbove() in Matchfield - Case: nothingBelow --- src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java | 4 +++- .../tims/fleetstorm/matchfield/MatchfieldCreationTest.java | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java b/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java index e803cee..9c86328 100644 --- a/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java +++ b/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()]; } diff --git a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java index edb160c..1936f86 100644 --- a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java +++ b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java @@ -90,7 +90,9 @@ class MatchfieldCreationTest { static Stream 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)); } }