From 8d012dd9b37295845a765534830a7181de72297f Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Fri, 18 Feb 2022 14:04:18 +0100 Subject: [PATCH] cleaned up RadioPlayer and made help functions package private --- src/main/java/device/radioPlayer/RadioPlayer.java | 6 +++--- src/test/java/device/radioPlayer/RadioPlayerTest.java | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index 0b341d4..7d9c503 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -24,7 +24,7 @@ public class RadioPlayer implements Device { int savedVolume; String playedStation; - public String getYouFMInfoByTime(int x) { + String getYouFMInfoByTime(int x) { if (x >= 5 && x < 10) return YouFMInfo[0]; else if (x >= 10 && x < 14) return YouFMInfo[1]; else if (x >= 14 && x < 18) return YouFMInfo[2]; @@ -36,7 +36,7 @@ public class RadioPlayer implements Device { String[] YouFMInfo = {"YOUFM Good Morning Show", "YOUFM Worktime", "YOUFM am Nachmittag", "YOUFM am Abend", "YOUFM Wir feiern euch", "YOUFM Deutschrap ideal", "YOUFM Junge Nacht der ARD"}; - public String getBR3InfoByTime(int x) { + String getBR3InfoByTime(int x) { if (x >= 5 && x < 9) return BR3Info[0]; else if (x >= 9 && x < 12) return BR3Info[1]; else if (x == 12) return BR3Info[2]; @@ -49,7 +49,7 @@ public class RadioPlayer implements Device { String[] BR3Info = {"Sebastian Winkler und die Frühaufdreher", "BAYERN 3 - und DU mittendrin!", "Update", "Hits, Hits, Hits für euren Nachmittag", "Die Zwei für euren Feierabend", "Was geht?!", "Matuschke - der etwas andere Abend", "Die Nacht"}; - public String getAntenneBYInfoByTime(int x) { + String getAntenneBYInfoByTime(int x) { if (x >= 5 && x < 9) return AntenneBYInfo[0]; else if (x >= 9 && x < 12) return AntenneBYInfo[1]; else if (x >= 12 && x < 15) return AntenneBYInfo[2]; diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 680109c..3cc6ad0 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -6,7 +6,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; - import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -104,9 +103,12 @@ class RadioPlayerTest { @ParameterizedTest @MethodSource("infoByTimeOptions") void infoByTimeInfo(String testName, RadioPlayer testRp, String testTyp, int hour, String expectedResult) { - if(testTyp.equals("YouFM")) assertThat(testRp.getYouFMInfoByTime(hour)).describedAs(testName).isEqualTo(expectedResult); - if(testTyp.equals("BR3")) assertThat(testRp.getBR3InfoByTime(hour)).describedAs(testName).isEqualTo(expectedResult); - if(testTyp.equals("AntenneBY")) assertThat(testRp.getAntenneBYInfoByTime(hour)).describedAs(testName).isEqualTo(expectedResult); + if (testTyp.equals("YouFM")) + assertThat(testRp.getYouFMInfoByTime(hour)).describedAs(testName).isEqualTo(expectedResult); + if (testTyp.equals("BR3")) + assertThat(testRp.getBR3InfoByTime(hour)).describedAs(testName).isEqualTo(expectedResult); + if (testTyp.equals("AntenneBY")) + assertThat(testRp.getAntenneBYInfoByTime(hour)).describedAs(testName).isEqualTo(expectedResult); } static Stream infoByTimeOptions() {