Pr_robot_factory/domain/R2D2.java

49 lines
1.2 KiB
Java

package domain;
import safety.robot_exceptions.ExceptionStorage;
import safety.robot_exceptions.RobotException;
import safety.robot_exceptions.robotExceptions;
import java.io.Serializable;
public class R2D2 extends Robot {
/**
*
* @param id> int
* @param name> String
*/
public R2D2(int id, String name){
super(id, name, "R2D2");
}
/**
* @see safety.interfaces.RobotInstructions
*/
public int[] think(int[] input) throws RobotException {
if(isPowerOn()){
return selectionSort(input);
}else{
RobotException robotexception = new RobotException(robotExceptions.ILLEGALSTATE, getName());
this.exceptions = new ExceptionStorage(robotexception);
throw robotexception;
}
}
/**
* @see safety.interfaces.RobotInstructions
*/
@Override
public String speak(int[] input) throws RobotException {
if (isPowerOn()) {
return ausgabe(input, ";");
} else {
RobotException robotexception = new RobotException(robotExceptions.ILLEGALSTATE, getName());
this.exceptions = new ExceptionStorage(robotexception);
throw robotexception;
}
}
}