From 01485b199b1317211307300576b8de9d0f23d6ff Mon Sep 17 00:00:00 2001 From: Max Wenzel Date: Wed, 12 Jan 2022 16:44:38 +0100 Subject: [PATCH] add getBelow() in Matchfield - DefaultCase --- .../de/tims/fleetstorm/matchfield/Matchfield.java | 5 +++++ .../matchfield/MatchfieldCreationTest.java | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java b/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java index 919bbe9..a02750a 100644 --- a/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java +++ b/src/main/java/de/tims/fleetstorm/matchfield/Matchfield.java @@ -62,4 +62,9 @@ public class Matchfield { return matchfield[center.getX()][center.getY() + 1]; } + public Coordinate getBelow(Coordinate center) { + // TODO Auto-generated method stub + 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 41f1790..5b165f8 100644 --- a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java +++ b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java @@ -111,4 +111,18 @@ class MatchfieldCreationTest { matchfield.getField(5, 6)), Arguments.of("above from (5/9) - should be null", matchfield, new Coordinate(5, 5), null)); } + + @ParameterizedTest(name = "Get the Coordinate below") + @MethodSource("getCoordinateBelow") + void testGetBelow(String testName, Matchfield matchfield, Coordinate center, Coordinate expectedResult) { + + Coordinate result = matchfield.getBelow(center); + assertThat(result).describedAs(testName).isEqualTo(expectedResult); + } + + 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))); + } }