2023-01-07 14:15:53 +01:00
|
|
|
package tpe.facade;
|
2023-01-03 12:14:11 +01:00
|
|
|
|
2023-01-08 19:02:39 +01:00
|
|
|
import tpe.exceptions.RobotException;
|
2023-01-03 12:14:11 +01:00
|
|
|
import tpe.exceptions.roboter.C3PO;
|
|
|
|
import tpe.exceptions.roboter.R2D2;
|
2023-01-08 19:02:39 +01:00
|
|
|
import tpe.exceptions.roboter.RobotFactory;
|
|
|
|
import tpe.exceptions.roboter.RobotType;
|
2023-01-03 12:14:11 +01:00
|
|
|
|
2023-01-07 18:48:00 +01:00
|
|
|
public class FactorySystem {
|
2023-01-08 19:02:39 +01:00
|
|
|
private RobotFactory rf;
|
|
|
|
RobotType robotType;
|
|
|
|
public FactorySystem(String factoryName)
|
|
|
|
{
|
|
|
|
this.rf=new RobotFactory(factoryName);
|
|
|
|
}
|
|
|
|
public int constructRobot(int select, String name) {
|
|
|
|
if(select==1) {
|
|
|
|
int id = rf.constructRobot(RobotType.R2D2, name);
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int id=rf.constructRobot(RobotType.C3PO, name);
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public boolean triggerPower(int id)
|
|
|
|
{
|
|
|
|
return rf.triggerPower(id);
|
|
|
|
}
|
|
|
|
public boolean powerStatus(int id)
|
|
|
|
{
|
|
|
|
return rf.powerStatus(id);
|
|
|
|
}
|
|
|
|
public String robotInfo(int id)
|
|
|
|
{
|
|
|
|
return rf.robotInfo(id);
|
|
|
|
}
|
|
|
|
public String dismantleRobot(int id)
|
|
|
|
{
|
|
|
|
if(rf.dismantleRobot(id)==null)
|
|
|
|
{
|
|
|
|
return "Roboter erfolgreich demontiert";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return "Fehler beim Demontieren des Roboters";
|
|
|
|
}
|
|
|
|
public RobotException robotBlackbox(int id)
|
|
|
|
{
|
|
|
|
return rf.robotBlackbox(id); //Bei Rückgabe von null gab es noch keinen Fehler
|
|
|
|
}
|
|
|
|
public String robotInstructions(int id, int[]zahlen) throws RobotException
|
|
|
|
{
|
|
|
|
return rf.robotInstructions(id, zahlen);
|
|
|
|
}
|
|
|
|
public int robotStockSize()
|
|
|
|
{
|
|
|
|
return rf.robotStockSize();
|
|
|
|
}
|
|
|
|
public boolean containsRobot(int id)
|
|
|
|
{
|
|
|
|
return rf.containsRobot(id);
|
|
|
|
}
|
2023-01-03 12:14:11 +01:00
|
|
|
}
|