From b2e104eff6d7ca24da4221ad57e1beee926585b0 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Thu, 10 Feb 2022 21:09:05 +0100 Subject: [PATCH] added complete code for getYouFMInfoByTime() & added Test for time 3:00 am --- src/main/java/device/radioPlayer/RadioPlayer.java | 5 +++++ src/test/java/device/radioPlayer/RadioPlayerTest.java | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/src/main/java/device/radioPlayer/RadioPlayer.java b/src/main/java/device/radioPlayer/RadioPlayer.java index b260bbd..1e944cf 100644 --- a/src/main/java/device/radioPlayer/RadioPlayer.java +++ b/src/main/java/device/radioPlayer/RadioPlayer.java @@ -18,6 +18,11 @@ public class RadioPlayer implements Device { public 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]; + else if (x >= 18 && x < 20) return YouFMInfo[3]; + else if (x >= 20 && x < 22) return YouFMInfo[4]; + else if (x >= 22 && x <= 23) return YouFMInfo[5]; else return YouFMInfo[6]; } diff --git a/src/test/java/device/radioPlayer/RadioPlayerTest.java b/src/test/java/device/radioPlayer/RadioPlayerTest.java index 042ea65..fe1f954 100644 --- a/src/test/java/device/radioPlayer/RadioPlayerTest.java +++ b/src/test/java/device/radioPlayer/RadioPlayerTest.java @@ -100,6 +100,12 @@ class RadioPlayerTest { RadioPlayer rp = new RadioPlayer(); assertThat(rp.getYouFMInfoByTime(8)).describedAs("YouFM info by Time at 8.00").isEqualTo("YOUFM Good Morning Show"); } + + @Test + void YouFMInfoByTime2Test() { + RadioPlayer rp = new RadioPlayer(); + assertThat(rp.getYouFMInfoByTime(3)).describedAs("YouFM info by Time at 3.00").isEqualTo("YOUFM Junge Nacht der ARD"); + } /* @Test