53 lines
1.2 KiB
Java
53 lines
1.2 KiB
Java
package facade;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import Domäne.C3PO;
|
|
import Domäne.R2D2;
|
|
import Domäne.RobotFactory;
|
|
import Domäne.RobotType;
|
|
import Domäne.Roboter;
|
|
import tpe.exceptions.roboter.exceptions.RobotException;
|
|
|
|
public class Factorysystem {
|
|
private RobotFactory robotFactory;
|
|
|
|
|
|
public Factorysystem (String name) {
|
|
this.robotFactory = new RobotFactory (name);
|
|
}
|
|
|
|
public int roboterAnlegen (String name, int auswahl) {
|
|
RobotType robottype;
|
|
if(auswahl == 1) {
|
|
robottype = RobotType.R2D2;
|
|
int id = robotFactory.addRobot(robottype, name);
|
|
return id;
|
|
} else if(auswahl == 2) {
|
|
robottype = RobotType.C3PO;
|
|
int id = robotFactory.addRobot(robottype, name);
|
|
return id;
|
|
}
|
|
return -1;
|
|
|
|
}
|
|
|
|
public boolean zustandRoboter (int id) {
|
|
return robotFactory.roboterZustand(id);
|
|
}
|
|
|
|
public boolean schalterBetätigen(int id) {
|
|
return robotFactory.schalterAnAus(id);
|
|
}
|
|
|
|
public String sprechenAufruf(int id, int[] zahlen) throws RobotException {
|
|
String ausgabe = robotFactory.aufrufSpeakAndThink(id, zahlen);
|
|
return ausgabe;
|
|
}
|
|
|
|
public RobotException fehlerAuslesen(int id) {
|
|
|
|
return robotFactory.letzterFehler(id);
|
|
}
|
|
}
|