Pr_robot_factory/domain/R2D2.java

47 lines
1.1 KiB
Java
Raw Normal View History

2022-12-08 14:58:44 +01:00
package domain;
2022-12-14 10:18:36 +01:00
import safety.robot_exceptions.ExceptionStorage;
import safety.robot_exceptions.RobotException;
import safety.robot_exceptions.robotExceptions;
2022-12-14 09:54:18 +01:00
2022-12-09 00:30:35 +01:00
public class R2D2 extends RobotBasics {
/**
*
* @param id> int
* @param name> String
*/
public R2D2(int id, String name){
super(id, name);
}
2022-12-25 19:57:20 +01:00
/**
* @see safety.interfaces.RobotInstructions
2022-12-25 19:57:20 +01:00
*/
public int[] think(int[] input) throws RobotException {
2022-12-14 10:18:36 +01:00
if(isPowerOn()){
return selectionSort(input);
2022-12-14 09:54:18 +01:00
}else{
2022-12-25 19:57:20 +01:00
RobotException robotexception = new RobotException(robotExceptions.ILLEGALSTATE, getName());
this.exceptions = new ExceptionStorage(robotexception);
throw robotexception;
2022-12-14 09:54:18 +01:00
}
}
2022-12-14 11:08:49 +01:00
/**
* @see safety.interfaces.RobotInstructions
2022-12-14 11:08:49 +01:00
*/
@Override
public String speak(int[] input) throws RobotException {
if (isPowerOn()) {
return ausgabe(input, ";");
} else {
2022-12-25 19:57:20 +01:00
RobotException robotexception = new RobotException(robotExceptions.ILLEGALSTATE, getName());
this.exceptions = new ExceptionStorage(robotexception);
throw robotexception;
2022-12-14 11:08:49 +01:00
}
}
2022-12-14 10:18:36 +01:00
}