From 27bcf334bbc62c513f0fb970d2a8aaff2e11f6e1 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Mon, 31 Jan 2022 20:50:17 +0100 Subject: [PATCH] RadioPlayer added quieter function + AssertJ test for quieter --- src/main/java/device/CDPlayer.java | 3 +-- src/main/java/device/Device.java | 5 +---- src/main/java/device/RadioPlayer.java | 11 ++++++----- src/main/java/device/UsbPlayer.java | 3 +-- src/test/java/device/CDPlayerTest.java | 4 +++- src/test/java/device/RadioPlayerTest.java | 6 +++++- src/test/java/device/UsbPlayerTest.java | 2 ++ 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/main/java/device/CDPlayer.java b/src/main/java/device/CDPlayer.java index 20929cc..4121a37 100644 --- a/src/main/java/device/CDPlayer.java +++ b/src/main/java/device/CDPlayer.java @@ -5,7 +5,7 @@ public class CDPlayer implements Device { public void louder() { } -/* + @Override public void quieter() { @@ -46,5 +46,4 @@ public class CDPlayer implements Device { return null; } - */ } diff --git a/src/main/java/device/Device.java b/src/main/java/device/Device.java index 84ccaa2..9b14cd3 100644 --- a/src/main/java/device/Device.java +++ b/src/main/java/device/Device.java @@ -3,10 +3,7 @@ package device; public interface Device { void louder(); - /* void quieter(); - - void quiter(); int getVolume(); void next(); void prev(); @@ -15,5 +12,5 @@ public interface Device { void chooseOption(String opt); String play(); - */ + } diff --git a/src/main/java/device/RadioPlayer.java b/src/main/java/device/RadioPlayer.java index 71d18e8..d1377ae 100644 --- a/src/main/java/device/RadioPlayer.java +++ b/src/main/java/device/RadioPlayer.java @@ -19,12 +19,15 @@ public class RadioPlayer implements Device { Lautstaerke = 100; } } - /* + @Override public void quieter() { - + if(Lautstaerke > 0) { + Lautstaerke -= 1; + } else { + Lautstaerke = 0; + } } - @Override public int getVolume() { return 0; @@ -59,6 +62,4 @@ public class RadioPlayer implements Device { public String play() { return null; } - - */ } diff --git a/src/main/java/device/UsbPlayer.java b/src/main/java/device/UsbPlayer.java index 350f203..5def7ab 100644 --- a/src/main/java/device/UsbPlayer.java +++ b/src/main/java/device/UsbPlayer.java @@ -6,7 +6,7 @@ public class UsbPlayer implements Device{ public void louder() { } -/* + @Override public void quieter() { @@ -47,5 +47,4 @@ public class UsbPlayer implements Device{ return null; } - */ } diff --git a/src/test/java/device/CDPlayerTest.java b/src/test/java/device/CDPlayerTest.java index bddf879..7658a13 100644 --- a/src/test/java/device/CDPlayerTest.java +++ b/src/test/java/device/CDPlayerTest.java @@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class CDPlayerTest { - +/* @Test void louder() { } @@ -41,4 +41,6 @@ class CDPlayerTest { @Test void play() { } + + */ } \ No newline at end of file diff --git a/src/test/java/device/RadioPlayerTest.java b/src/test/java/device/RadioPlayerTest.java index 22c525d..70eb705 100644 --- a/src/test/java/device/RadioPlayerTest.java +++ b/src/test/java/device/RadioPlayerTest.java @@ -22,11 +22,15 @@ class RadioPlayerTest { rp.louder(); assertThat(rp.getLautstaerke()).isEqualTo(100); } -/* + @Test void quieter() { + rp.setLautstaerke(1); + rp.quieter(); + assertThat(rp.getLautstaerke()).isEqualTo(0); } +/* @Test void getVolume() { } diff --git a/src/test/java/device/UsbPlayerTest.java b/src/test/java/device/UsbPlayerTest.java index be7d232..a638c8a 100644 --- a/src/test/java/device/UsbPlayerTest.java +++ b/src/test/java/device/UsbPlayerTest.java @@ -6,6 +6,7 @@ import static org.junit.jupiter.api.Assertions.*; class UsbPlayerTest { +/* @Test void louder() { } @@ -41,4 +42,5 @@ class UsbPlayerTest { @Test void play() { } + */ } \ No newline at end of file