diff --git a/src/main/java/device/usbPlayer/UsbPlayer.java b/src/main/java/device/usbPlayer/UsbPlayer.java index 6d8f2a0..c9e15c2 100644 --- a/src/main/java/device/usbPlayer/UsbPlayer.java +++ b/src/main/java/device/usbPlayer/UsbPlayer.java @@ -12,7 +12,7 @@ public class UsbPlayer implements Device { private Boolean isConnected; private Boolean isDefect; int Lautstaerke = 0; - int soundWas ; + int soundWas =-1; public USB_Stick USBDrive = new USB_Stick(); @@ -104,11 +104,14 @@ public class UsbPlayer implements Device { //**********search method************* @Override public void quieter() { - if (Lautstaerke > 0) { - Lautstaerke -= 1; - } else { - Lautstaerke = 0; + if(this.soundWas == -1){ + if (Lautstaerke > 0 ) { + Lautstaerke -= 1; + } else { + Lautstaerke = 0; + } } + } @Override @@ -193,7 +196,7 @@ public class UsbPlayer implements Device { public String unmute() { setLautstaerke(soundWas); - this.soundWas = 0; + this.soundWas = -1; return "unmuted"; } diff --git a/src/test/java/device/usbPlayer/UsbPlayerTest.java b/src/test/java/device/usbPlayer/UsbPlayerTest.java index f15d636..202aef3 100644 --- a/src/test/java/device/usbPlayer/UsbPlayerTest.java +++ b/src/test/java/device/usbPlayer/UsbPlayerTest.java @@ -79,14 +79,25 @@ class UsbPlayerTest { static Stream quieterOptions() { USB_Stick USBDrive = new USB_Stick(); + //first case UsbPlayer up1 = new UsbPlayer(USBDrive); up1.quieter(); + //second case UsbPlayer up2 = new UsbPlayer(USBDrive); up2.setLautstaerke(10); up2.quieter(); + + //third case + UsbPlayer up3 = new UsbPlayer(USBDrive); + up3.setLautstaerke(10); + up3.mute(); + up3.quieter(); + return Stream.of( Arguments.of("Volume must stay 0 ", up1, 0), - Arguments.of("Volume must be 9 ", up2, 9) + Arguments.of("Volume must be 9 ", up2, 9), + Arguments.of("Volume is muted,no change can be made ", up3, 0) + ); }