diff --git a/exercises/concept/football-match-reports/.docs/instructions.md b/exercises/concept/football-match-reports/.docs/instructions.md index f255c3a13..2c668b663 100644 --- a/exercises/concept/football-match-reports/.docs/instructions.md +++ b/exercises/concept/football-match-reports/.docs/instructions.md @@ -27,11 +27,11 @@ FootballMatchReports.onField(10); // => "striker" ``` -## 2. Raise an alert if an unknown shirt number is encountered +## 2. Output "invalid" if the shirt number is not part of the official list -Modify the `FootballMatchReports.onField()` method to throw an `IllegalArgumentException` when a shirt number outside the range 1-11 is processed. +Modify the `FootballMatchReports.onField()` method to return 'invalid' when a shirt number outside the range 1-11 is processed. ```java FootballMatchReports.onField(13); -// => Throw IllegalArgumentException +// => "invalid" ``` diff --git a/exercises/concept/football-match-reports/.meta/config.json b/exercises/concept/football-match-reports/.meta/config.json index 9b291514e..74d3894b7 100644 --- a/exercises/concept/football-match-reports/.meta/config.json +++ b/exercises/concept/football-match-reports/.meta/config.json @@ -2,6 +2,9 @@ "authors": [ "Azumix" ], + "contributors": [ + "AlvesJorge" + ], "files": { "solution": [ "src/main/java/FootballMatchReports.java" diff --git a/exercises/concept/football-match-reports/.meta/src/reference/java/FootballMatchReports.java b/exercises/concept/football-match-reports/.meta/src/reference/java/FootballMatchReports.java index d18f55ac6..c99abc7b0 100644 --- a/exercises/concept/football-match-reports/.meta/src/reference/java/FootballMatchReports.java +++ b/exercises/concept/football-match-reports/.meta/src/reference/java/FootballMatchReports.java @@ -30,7 +30,7 @@ public static String onField(int shirtNum) { playerDescription = "striker"; break; default: - throw new IllegalArgumentException(); + playerDescription = "invalid"; } return playerDescription; } diff --git a/exercises/concept/football-match-reports/src/test/java/FootballMatchReportsTest.java b/exercises/concept/football-match-reports/src/test/java/FootballMatchReportsTest.java index aeaeada1d..7c45eb1a7 100644 --- a/exercises/concept/football-match-reports/src/test/java/FootballMatchReportsTest.java +++ b/exercises/concept/football-match-reports/src/test/java/FootballMatchReportsTest.java @@ -3,7 +3,6 @@ import org.junit.jupiter.api.Test; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; public class FootballMatchReportsTest { @@ -68,17 +67,15 @@ public void test_right_wing() { @Test @Tag("task:2") - @DisplayName("The onField method throws IllegalArgumentException for unknown shirt number") + @DisplayName("The onField method returns 'invalid' for invalid shirt number") public void test_exception() { - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> FootballMatchReports.onField(13)); + assertThat(FootballMatchReports.onField(13)).isEqualTo("invalid"); } @Test @Tag("task:2") - @DisplayName("The onField method throws IllegalArgumentException for negative shirt number") + @DisplayName("The onField method returns 'invalid' for negative shirt number") public void test_exception_negative_number() { - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> FootballMatchReports.onField(-1)); + assertThat(FootballMatchReports.onField(-1)).isEqualTo("invalid"); } }