2023-01-07 14:15:53 +01:00
|
|
|
package tpe.facade;
|
2023-01-03 12:14:11 +01:00
|
|
|
|
2023-01-09 17:59:48 +01:00
|
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
import de.hs_mannheim.informatik.bank.domain.Konto;
|
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-09 17:59:48 +01:00
|
|
|
import tpe.exceptions.roboter.Robots;
|
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;
|
2023-01-09 07:59:01 +01:00
|
|
|
|
|
|
|
public FactorySystem(String factoryName) {
|
|
|
|
this.rf = new RobotFactory(factoryName);
|
2023-01-08 19:02:39 +01:00
|
|
|
}
|
2023-01-09 07:59:01 +01:00
|
|
|
|
2023-01-08 19:02:39 +01:00
|
|
|
public int constructRobot(int select, String name) {
|
2023-01-09 07:59:01 +01:00
|
|
|
if (select == 1) {
|
|
|
|
int id = rf.constructRobot(RobotType.R2D2, name);
|
|
|
|
return id;
|
2023-01-09 17:36:33 +01:00
|
|
|
} else {
|
2023-01-09 07:59:01 +01:00
|
|
|
int id = rf.constructRobot(RobotType.C3PO, name);
|
2023-01-08 19:02:39 +01:00
|
|
|
return id;
|
|
|
|
}
|
2023-01-09 17:36:33 +01:00
|
|
|
|
|
|
|
|
2023-01-08 19:02:39 +01:00
|
|
|
}
|
2023-01-09 07:59:01 +01:00
|
|
|
|
|
|
|
public boolean triggerPower(int id) {
|
2023-01-08 19:02:39 +01:00
|
|
|
return rf.triggerPower(id);
|
|
|
|
}
|
2023-01-09 07:59:01 +01:00
|
|
|
|
|
|
|
public boolean powerStatus(int id) {
|
2023-01-08 19:02:39 +01:00
|
|
|
return rf.powerStatus(id);
|
|
|
|
}
|
2023-01-09 07:59:01 +01:00
|
|
|
|
2023-01-09 17:36:33 +01:00
|
|
|
// public String robotInfo(int id) {
|
|
|
|
// return rf.robotInfo(id).toString();
|
|
|
|
// }
|
2023-01-09 07:59:01 +01:00
|
|
|
|
|
|
|
|
|
|
|
public RobotException robotBlackbox(int id) {
|
|
|
|
return rf.robotBlackbox(id); // Bei Rückgabe von null gab es noch keinen Fehler
|
2023-01-08 19:02:39 +01:00
|
|
|
}
|
2023-01-09 07:59:01 +01:00
|
|
|
|
|
|
|
public String robotInstructions(int id, int[] zahlen) throws RobotException {
|
2023-01-08 19:02:39 +01:00
|
|
|
return rf.robotInstructions(id, zahlen);
|
|
|
|
}
|
2023-01-09 07:59:01 +01:00
|
|
|
|
|
|
|
public int robotStockSize() {
|
2023-01-08 19:02:39 +01:00
|
|
|
return rf.robotStockSize();
|
|
|
|
}
|
2023-01-09 07:59:01 +01:00
|
|
|
|
|
|
|
public boolean containsRobot(int id) {
|
2023-01-08 19:02:39 +01:00
|
|
|
return rf.containsRobot(id);
|
|
|
|
}
|
2023-01-09 07:59:01 +01:00
|
|
|
|
|
|
|
public String getFName() {
|
|
|
|
return rf.getFactoryName();
|
|
|
|
}
|
2023-01-09 17:59:48 +01:00
|
|
|
public String[] getRobotStock() {
|
|
|
|
Collection<Robots> robotStock = rf.getRobotStock();
|
|
|
|
String[] liste = new String[robotStock.size()];
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
for (Robots r : robotStock) {
|
|
|
|
liste[i++] = r.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
return liste;
|
|
|
|
}
|
2023-01-03 12:14:11 +01:00
|
|
|
}
|