From 435e15be50bc12f5dc70623cbe3b8c105e2a796a Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 21:22:35 +0100 Subject: [PATCH] added getAntenneBYInfoByTime() & added Tests --- src/main/java/device/radioPlayer/RadioPlayer.java | 13 +++++++++++++ .../java/device/radioPlayer/RadioPlayerTest.java | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index 1e944cf..bf24e5b 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -2,6 +2,7 @@ package device.radioPlayer; import device.Device; +import java.time.LocalDateTime; import java.util.ArrayList; public class RadioPlayer implements Device { @@ -15,6 +16,8 @@ public class RadioPlayer implements Device { } ArrayList Playlist=new ArrayList(); + LocalDateTime now = LocalDateTime.now(); + int hour = now.getHour(); public String getYouFMInfoByTime(int x) { if(x >= 5 && x <10 ) return YouFMInfo[0]; @@ -28,6 +31,16 @@ 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 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]; + else if (x >= 15 && x < 19) return AntenneBYInfo[3]; + else return AntenneBYInfo[4]; + } + + String[] AntenneBYInfo = {"ANTENNE BAYERN Guten Morgen Bayern", "ANTENNE BAYERN bei der Arbeit", "ANTENNE BAYERN am Nachmittag", "ANTENNE BAYERN am Abend", "ANTENNE BAYERN Hit-Nacht"}; + int Lautstaerke = 0; String playTrack=""; diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index fe1f954..e97d7f9 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -106,6 +106,20 @@ class RadioPlayerTest { RadioPlayer rp = new RadioPlayer(); assertThat(rp.getYouFMInfoByTime(3)).describedAs("YouFM info by Time at 3.00").isEqualTo("YOUFM Junge Nacht der ARD"); } + + @Test + void AntenneBYInfoByTimeTest() { + RadioPlayer rp = new RadioPlayer(); + assertThat(rp.getAntenneBYInfoByTime(8)).describedAs("AntenneBY info by Time at 8.00").isEqualTo("ANTENNE BAYERN Guten Morgen Bayern"); + } + + @Test + void AntenneBYInfoByTime2Test() { + RadioPlayer rp = new RadioPlayer(); + assertThat(rp.getAntenneBYInfoByTime(3)).describedAs("AntenneBY info by Time at 3.00").isEqualTo("ANTENNE BAYERN Hit-Nacht"); + } + + /* @Test