From 96777543b486e1bf49a019c2839fda66b9f11d50 Mon Sep 17 00:00:00 2001 From: alpina0707 Date: Mon, 31 Jan 2022 20:09:59 +0100 Subject: [PATCH] implemented Lautstraerke & function louder for RadioPlayer + AssertJ test for louder --- src/main/java/device/CDPlayer.java | 4 +++- src/main/java/device/Device.java | 5 +++++ src/main/java/device/RadioPlayer.java | 20 +++++++++++++++-- src/main/java/device/UsbPlayer.java | 4 +++- src/test/java/device/RadioPlayerTest.java | 26 ++++++++++++++++++++++- 5 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/main/java/device/CDPlayer.java b/src/main/java/device/CDPlayer.java index 60e42e5..20929cc 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() { @@ -45,4 +45,6 @@ public class CDPlayer implements Device { public String play() { return null; } + + */ } diff --git a/src/main/java/device/Device.java b/src/main/java/device/Device.java index eadfffe..84ccaa2 100644 --- a/src/main/java/device/Device.java +++ b/src/main/java/device/Device.java @@ -3,7 +3,10 @@ package device; public interface Device { void louder(); + /* void quieter(); + + void quiter(); int getVolume(); void next(); void prev(); @@ -11,4 +14,6 @@ public interface Device { String[] getOptions(); void chooseOption(String opt); String play(); + + */ } diff --git a/src/main/java/device/RadioPlayer.java b/src/main/java/device/RadioPlayer.java index 603453b..71d18e8 100644 --- a/src/main/java/device/RadioPlayer.java +++ b/src/main/java/device/RadioPlayer.java @@ -1,11 +1,25 @@ package device; public class RadioPlayer implements Device { - @Override - public void louder() { + public void setLautstaerke(int lautstaerke) { + Lautstaerke = lautstaerke; + } + + public int getLautstaerke() { + return Lautstaerke; } + int Lautstaerke = 0; + @Override + public void louder() { + if(Lautstaerke < 100) { + Lautstaerke += 1; + } else { + Lautstaerke = 100; + } + } + /* @Override public void quieter() { @@ -45,4 +59,6 @@ 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 4c01207..350f203 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() { @@ -46,4 +46,6 @@ public class UsbPlayer implements Device{ public String play() { return null; } + + */ } diff --git a/src/test/java/device/RadioPlayerTest.java b/src/test/java/device/RadioPlayerTest.java index 50a756a..124d995 100644 --- a/src/test/java/device/RadioPlayerTest.java +++ b/src/test/java/device/RadioPlayerTest.java @@ -1,17 +1,39 @@ package device; +import org.junit.Before; import org.junit.jupiter.api.Test; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.*; class RadioPlayerTest { + RadioPlayer rp = new RadioPlayer(); + + @Before + void setup() + { + rp.setLautstaerke(0); + } @Test void louder() { + rp.louder(); + assertThat(rp.getLautstaerke()).isEqualTo(1); + } + + @Before + void setup1() + { + rp.setLautstaerke(100); } @Test - void quiter() { + void loudermax() { + + } +/* + @Test + void quieter() { } @Test @@ -41,4 +63,6 @@ class RadioPlayerTest { @Test void play() { } + + */ } \ No newline at end of file