|
@ -1,4 +1,8 @@ |
|
|
import device.Device; |
|
|
import device.Device; |
|
|
|
|
|
import device.cdPlayer.CD; |
|
|
|
|
|
import device.cdPlayer.CDPlayer; |
|
|
|
|
|
import device.radioPlayer.RadioPlayer; |
|
|
|
|
|
import device.usbPlayer.UsbPlayer; |
|
|
|
|
|
|
|
|
import java.io.FileReader; |
|
|
import java.io.FileReader; |
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
import java.lang.reflect.InvocationTargetException; |
|
@ -35,4 +39,43 @@ public class BordComputer { |
|
|
installedDevices[i] = (Device) c.getConstructor().newInstance(); |
|
|
installedDevices[i] = (Device) c.getConstructor().newInstance(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String play(){ |
|
|
|
|
|
String itemToPlay=activeDevice.play(); |
|
|
|
|
|
return itemToPlay; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//===== Hilf-Funktionen ====== |
|
|
|
|
|
|
|
|
|
|
|
public Object getInstanceByName(String deviceName){ |
|
|
|
|
|
for (int i = 0; i <installedDevices.length ; i++) { |
|
|
|
|
|
if(installedDevices[i].getClass().getSimpleName().equals(deviceName)){ |
|
|
|
|
|
if(deviceName.equals("CDPlayer")){ |
|
|
|
|
|
return (CDPlayer)installedDevices[i]; |
|
|
|
|
|
} |
|
|
|
|
|
if(deviceName.equals("RadioPlayer")){ |
|
|
|
|
|
return (RadioPlayer)installedDevices[i]; |
|
|
|
|
|
} |
|
|
|
|
|
if(deviceName.equals("UsbPlayer")){ |
|
|
|
|
|
return (UsbPlayer)installedDevices[i]; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
public void meetAllPreconditionForPlay(){ |
|
|
|
|
|
|
|
|
|
|
|
String[] audioPlayList = new String[]{"Audio 01", "Audio 02", "Audio 03", "Audio 04", "Audio 05"}; |
|
|
|
|
|
CD audioCD1 = new CD("Audio", "PopMusic", audioPlayList, "XAc20044"); |
|
|
|
|
|
CD audioCD2=new CD("Audio","RockMusic",audioPlayList,"BLXPP78"); |
|
|
|
|
|
|
|
|
|
|
|
CDPlayer cdPlayer=(CDPlayer) activeDevice; |
|
|
|
|
|
cdPlayer.changePlaySource(); |
|
|
|
|
|
cdPlayer.loadCDWechseler(audioCD1, 0); |
|
|
|
|
|
cdPlayer.loadCDWechseler(audioCD2, 1); |
|
|
|
|
|
|
|
|
|
|
|
cdPlayer.setCD(cdPlayer.getCdWechseler().getCDList().get(0)); |
|
|
|
|
|
activeDevice=cdPlayer; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |