package domain; import roboter.exceptions.RobotException; import roboter.exceptions.RobotIllegalStateException; public class RobotBasics implements Robot { private int id; private String name; private boolean power; public RobotBasics(int id, String name){ this.id = id; this.name = name; this.power = false; } /** * @see domain.RobotControl */ @Override public int getId() { return id; } /** * @see domain.RobotControl */ @Override public String getName() { return name; } /** * @see domain.RobotControl */ @Override public void triggerPowerSwitch() { if(power == false){ power = true; }else{ power = false; } } /** * @see domain.RobotControl */ @Override public boolean isPowerOn() { return power; } /** * @see roboter.RobotInstructions */ @Override public String speak(int[] zahlen) throws RobotException { if(power == true){ String array = ""; for(int i = 0; i < zahlen.length; i++){ array += zahlen[i] + " "; } return array; }else{ throw new RobotIllegalStateException("The Robot is turned off."); } } /** * @see roboter.RobotInstructions */ @Override public int[] think(int[] zahlen) throws RobotException { return new int[0]; } }