Drees 2023-01-09 07:04:44 +01:00
commit c1494b6dbc
2 changed files with 59 additions and 4 deletions

View File

@ -22,12 +22,12 @@ public class RobotFactory {
robotStock.put(robot.getId(), robot); robotStock.put(robot.getId(), robot);
return robot.getId(); return robot.getId();
} }
else if(RobotType.C3PO==robotType) { else {
robot=new C3PO(name, createIDC3PO(10000, 19999)); robot=new C3PO(name, createIDC3PO(10000, 19999));
robotStock.put(robot.getId(), robot); robotStock.put(robot.getId(), robot);
return robot.getId(); return robot.getId();
} }
else return 0; // Müsste hier nicht noch was für den Nexus stehen?
} }
private int createIDR2D2(int minValue, int maxValue) { private int createIDR2D2(int minValue, int maxValue) {

View File

@ -1,9 +1,64 @@
package tpe.facade; package tpe.facade;
import tpe.exceptions.RobotException;
import tpe.exceptions.roboter.C3PO; import tpe.exceptions.roboter.C3PO;
import tpe.exceptions.roboter.R2D2; import tpe.exceptions.roboter.R2D2;
import tpe.exceptions.roboter.RobotFactory;
import tpe.exceptions.roboter.RobotType;
public class FactorySystem { public class FactorySystem {
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);
}
} }