@ -184,7 +184,7 @@ public class UsbPlayer implements Device {
@Override
public String chooseItem(int itemNr) {
String songName="";
if (itemNr < this.getPlaylist().size()) {
if (itemNr < this.getPlaylist().size() && itemNr >= 0) {
songName= this.getPlaylist().get(itemNr ).toString();
}
return songName;
@ -557,7 +557,8 @@ class UsbPlayerTest {
UsbPlayer up1 = new UsbPlayer(USBDrive);
return Stream.of(
Arguments.of("An Item from the Album was chosen ", up1.chooseItem(0), "Musik 01.mp3")
Arguments.of("An Item from the Album was chosen ", up1.chooseItem(0), "Musik 01.mp3"),
Arguments.of("Incorrect Nr of Item was given ", up1.chooseItem(-1), "")
);