diff --git a/src/main/java/BordComputer.java b/src/main/java/BordComputer.java index 38d24d1..439078e 100644 --- a/src/main/java/BordComputer.java +++ b/src/main/java/BordComputer.java @@ -1,4 +1,6 @@ import device.Device; +import device.cdPlayer.CD; +import device.cdPlayer.CDPlayer; import java.io.FileReader; import java.lang.reflect.InvocationTargetException; @@ -46,6 +48,22 @@ public class BordComputer { //setting activeDevice activeDevice = installedDevices[0]; - return null; + String infoText=""; + if(activeDevice instanceof CDPlayer){ + CDPlayer cdPlayer=(CDPlayer) activeDevice; + String[] audioPlayList=new String[]{"Audio 01","Audio 02","Audio 03","Audio 04","Audio 05"}; + //some CDs + CD audioCD1=new CD("Audio",audioPlayList); + audioCD1.setAlbumName("Love Songs"); + + cdPlayer.tapOnCdFlap(); + cdPlayer.setCD(audioCD1); + cdPlayer.tapOnCdFlap(); + cdPlayer.setInfoText(); + infoText = cdPlayer.getInfoText(); + }else{ + infoText=activeDevice.getInfoText()+" ist activate"; + } + return infoText; } } diff --git a/src/test/java/BordComputerTest.java b/src/test/java/BordComputerTest.java index 056b5f3..422d7ef 100644 --- a/src/test/java/BordComputerTest.java +++ b/src/test/java/BordComputerTest.java @@ -92,6 +92,8 @@ class BordComputerTest { }else if (caseNr == 2) { Device currentDevice = inputBC.activeDevice; assertThat(currentDevice).describedAs(testName).isNotEqualTo(prvDevice); + }else if (caseNr == 3) { + assertThat(inputBC.changeDevice()).describedAs(testName).isNotNull(); } } @@ -112,11 +114,18 @@ class BordComputerTest { Device prvDevice = bc1.activeDevice; m =bc1.changeDevice(); + //third case + BordComputer bc2 = new BordComputer(); + bc2.readConfig(); + bc2.setDevices(); + m =bc2.changeDevice(); + return Stream.of( Arguments.of("The order of the installedDevices should be changed ", bc,currentDevices,null,"",1), - Arguments.of("The active Device should be changed ", bc1,null,prvDevice,"",2) + Arguments.of("The active Device should be changed ", bc1,null,prvDevice,"",2), + Arguments.of("The new Device returns a String ", bc2,null,prvDevice,bc2.activeDevice.toString(),3) ); } } \ No newline at end of file