From 4f1656e4dd2589378edc04aab1f3ae87b05b4a13 Mon Sep 17 00:00:00 2001 From: Jan Ortner Date: Sat, 5 Feb 2022 14:36:08 +0100 Subject: [PATCH 1/3] implemented RadioPlayer function next & JUnit for this function --- src/main/java/device/RadioPlayer.java | 20 ++++++++++++++++++-- src/test/java/device/RadioPlayerTest.java | 10 +++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/device/RadioPlayer.java b/src/main/java/device/RadioPlayer.java index d1377ae..5ca1848 100644 --- a/src/main/java/device/RadioPlayer.java +++ b/src/main/java/device/RadioPlayer.java @@ -1,7 +1,21 @@ package device; +import java.util.ArrayList; + public class RadioPlayer implements Device { + public RadioPlayer() { + super(); + Playlist.add("Radio YouFM"); + Playlist.add("Radio Teddy"); + Playlist.add("Radio MegaHits"); + playTrack=Playlist.get(0); + } + + ArrayList Playlist=new ArrayList(); + int Lautstaerke = 0; + String playTrack=""; + public void setLautstaerke(int lautstaerke) { Lautstaerke = lautstaerke; } @@ -10,7 +24,7 @@ public class RadioPlayer implements Device { return Lautstaerke; } - int Lautstaerke = 0; + @Override public void louder() { if(Lautstaerke < 100) { @@ -35,7 +49,9 @@ public class RadioPlayer implements Device { @Override public void next() { - + int currentIndex=Playlist.indexOf(playTrack); + int nextIndex=(currentIndex+1)%Playlist.size(); + playTrack=Playlist.get(nextIndex); } @Override diff --git a/src/test/java/device/RadioPlayerTest.java b/src/test/java/device/RadioPlayerTest.java index 9cdbea2..873eb64 100644 --- a/src/test/java/device/RadioPlayerTest.java +++ b/src/test/java/device/RadioPlayerTest.java @@ -36,18 +36,18 @@ class RadioPlayerTest { assertThat(rp.getLautstaerke()).isEqualTo(0); } /* -Test3 for Jeninks Pipeline reaction to Pull request -hopefully last test2 -test for pr only @Test void getVolume() { } - +*/ @Test void next() { + rp.next(); + int currentIndex=rp.Playlist.indexOf(rp.playTrack); + assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size())); } - +/* @Test void prev() { } From 21bc4889793851d9c6d82c3397952de9bfd72397 Mon Sep 17 00:00:00 2001 From: Jan Ortner Date: Sat, 5 Feb 2022 15:10:18 +0100 Subject: [PATCH 2/3] test RadioPlayer prev --- src/test/java/device/RadioPlayerTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/device/RadioPlayerTest.java b/src/test/java/device/RadioPlayerTest.java index 873eb64..c84c1bb 100644 --- a/src/test/java/device/RadioPlayerTest.java +++ b/src/test/java/device/RadioPlayerTest.java @@ -48,6 +48,7 @@ class RadioPlayerTest { assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size())); } /* + pr test2.0 @Test void prev() { } From 5643e008ff42ed27a85f804affcdb6559ed911a0 Mon Sep 17 00:00:00 2001 From: Jan Ortner Date: Sat, 5 Feb 2022 15:21:33 +0100 Subject: [PATCH 3/3] test RadioPlayer prev --- src/test/java/device/RadioPlayerTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/device/RadioPlayerTest.java b/src/test/java/device/RadioPlayerTest.java index c84c1bb..d206e28 100644 --- a/src/test/java/device/RadioPlayerTest.java +++ b/src/test/java/device/RadioPlayerTest.java @@ -48,7 +48,7 @@ class RadioPlayerTest { assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size())); } /* - pr test2.0 + @Test void prev() { }