Browse Source

implemented Lautstraerke & function louder for RadioPlayer + AssertJ test for louder

feature-dev-rp_prev
alpina0707 3 years ago
parent
commit
96777543b4
  1. 4
      src/main/java/device/CDPlayer.java
  2. 5
      src/main/java/device/Device.java
  3. 20
      src/main/java/device/RadioPlayer.java
  4. 4
      src/main/java/device/UsbPlayer.java
  5. 26
      src/test/java/device/RadioPlayerTest.java

4
src/main/java/device/CDPlayer.java

@ -5,7 +5,7 @@ public class CDPlayer implements Device {
public void louder() { public void louder() {
} }
/*
@Override @Override
public void quieter() { public void quieter() {
@ -45,4 +45,6 @@ public class CDPlayer implements Device {
public String play() { public String play() {
return null; return null;
} }
*/
} }

5
src/main/java/device/Device.java

@ -3,7 +3,10 @@ package device;
public interface Device { public interface Device {
void louder(); void louder();
/*
void quieter(); void quieter();
void quiter();
int getVolume(); int getVolume();
void next(); void next();
void prev(); void prev();
@ -11,4 +14,6 @@ public interface Device {
String[] getOptions(); String[] getOptions();
void chooseOption(String opt); void chooseOption(String opt);
String play(); String play();
*/
} }

20
src/main/java/device/RadioPlayer.java

@ -1,11 +1,25 @@
package device; package device;
public class RadioPlayer implements 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 @Override
public void quieter() { public void quieter() {
@ -45,4 +59,6 @@ public class RadioPlayer implements Device {
public String play() { public String play() {
return null; return null;
} }
*/
} }

4
src/main/java/device/UsbPlayer.java

@ -6,7 +6,7 @@ public class UsbPlayer implements Device{
public void louder() { public void louder() {
} }
/*
@Override @Override
public void quieter() { public void quieter() {
@ -46,4 +46,6 @@ public class UsbPlayer implements Device{
public String play() { public String play() {
return null; return null;
} }
*/
} }

26
src/test/java/device/RadioPlayerTest.java

@ -1,17 +1,39 @@
package device; package device;
import org.junit.Before;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
class RadioPlayerTest { class RadioPlayerTest {
RadioPlayer rp = new RadioPlayer();
@Before
void setup()
{
rp.setLautstaerke(0);
}
@Test @Test
void louder() { void louder() {
rp.louder();
assertThat(rp.getLautstaerke()).isEqualTo(1);
}
@Before
void setup1()
{
rp.setLautstaerke(100);
} }
@Test @Test
void quiter() {
void loudermax() {
}
/*
@Test
void quieter() {
} }
@Test @Test
@ -41,4 +63,6 @@ class RadioPlayerTest {
@Test @Test
void play() { void play() {
} }
*/
} }
Loading…
Cancel
Save