diff --git a/src/main/java/device/RadioPlayer.java b/src/main/java/device/RadioPlayer.java index 5ca1848..4fe0a05 100644 --- a/src/main/java/device/RadioPlayer.java +++ b/src/main/java/device/RadioPlayer.java @@ -56,7 +56,10 @@ public class RadioPlayer implements Device { @Override public void prev() { - + int currentIndex=Playlist.indexOf(playTrack); + int nextIndex=Playlist.size()-1; + if(currentIndex!=0){nextIndex=(currentIndex-1);} + playTrack=Playlist.get(nextIndex); } @Override diff --git a/src/test/java/device/RadioPlayerTest.java b/src/test/java/device/RadioPlayerTest.java index d206e28..edb8bd3 100644 --- a/src/test/java/device/RadioPlayerTest.java +++ b/src/test/java/device/RadioPlayerTest.java @@ -47,12 +47,16 @@ class RadioPlayerTest { int currentIndex=rp.Playlist.indexOf(rp.playTrack); assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size())); } -/* + @Test void prev() { - } + rp.prev(); + int currentIndex=rp.Playlist.indexOf(rp.playTrack); + assertThat(rp.playTrack).isEqualTo(rp.Playlist.get((currentIndex)%rp.Playlist.size())); + } +/* @Test void getInfoText() { }