From 66e3394f09274e0b80373267058880f9851e685d Mon Sep 17 00:00:00 2001 From: Max Wenzel Date: Wed, 12 Jan 2022 16:48:10 +0100 Subject: [PATCH] add getBelow() 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 a02750a..45b08c4 100644 --- a/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java +++ b/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java @@ -63,7 +63,9 @@ public class Matchfield { } public Coordinate getBelow(Coordinate center) { - // TODO Auto-generated method stub + if (center.getY() == 0) { + return null; + } return matchfield[center.getX()][center.getY() - 1]; } diff --git a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java index 5b165f8..6db8108 100644 --- a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java +++ b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java @@ -122,7 +122,9 @@ class MatchfieldCreationTest { static Stream getCoordinateBelow() { 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)); } }