Browse Source

added getAntenneBYInfoByTime() & added Tests

feature-pr-getVolume
Jan Ortner 3 years ago
parent
commit
435e15be50
  1. 13
      src/main/java/device/radioPlayer/RadioPlayer.java
  2. 14
      src/test/java/device/radioPlayer/RadioPlayerTest.java

13
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<String> Playlist=new ArrayList<String>();
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="";

14
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

Loading…
Cancel
Save