Browse Source

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

pull/1/head
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() {
}
/*
@Override
public void quieter() {
@ -45,4 +45,6 @@ public class CDPlayer implements Device {
public String play() {
return null;
}
*/
}

5
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();
*/
}

20
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;
}
*/
}

4
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;
}
*/
}

26
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() {
}
*/
}
Loading…
Cancel
Save