2022-12-09 00:29:00 +01:00
|
|
|
package domain;
|
|
|
|
|
2022-12-09 10:45:51 +01:00
|
|
|
import robot.exceptions.RobotException;
|
|
|
|
import robot.exceptions.RobotIllegalStateException;
|
|
|
|
import robot.interfaces.Robot;
|
|
|
|
import robot.interfaces.RobotControl;
|
|
|
|
import robot.interfaces.RobotInstructions;
|
|
|
|
|
2022-12-09 01:38:11 +01:00
|
|
|
|
|
|
|
public class RobotBasics implements Robot {
|
2022-12-09 00:29:00 +01:00
|
|
|
private int id;
|
|
|
|
private String name;
|
|
|
|
private boolean power;
|
|
|
|
|
2022-12-09 01:38:11 +01:00
|
|
|
public RobotBasics(int id, String name){
|
|
|
|
this.id = id;
|
|
|
|
this.name = name;
|
|
|
|
this.power = false;
|
|
|
|
}
|
2022-12-09 00:29:00 +01:00
|
|
|
/**
|
2022-12-09 10:45:51 +01:00
|
|
|
* @see RobotControl
|
2022-12-09 00:29:00 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public int getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-12-09 10:45:51 +01:00
|
|
|
* @see RobotControl
|
2022-12-09 00:29:00 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-12-09 10:45:51 +01:00
|
|
|
* @see RobotControl
|
2022-12-09 00:29:00 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void triggerPowerSwitch() {
|
2022-12-09 01:38:11 +01:00
|
|
|
if(power == false){
|
|
|
|
power = true;
|
|
|
|
}else{
|
|
|
|
power = false;
|
|
|
|
}
|
2022-12-09 00:29:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-12-09 10:45:51 +01:00
|
|
|
* @see RobotControl
|
2022-12-09 00:29:00 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean isPowerOn() {
|
|
|
|
return power;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-12-09 10:45:51 +01:00
|
|
|
* @see RobotInstructions
|
2022-12-09 00:29:00 +01:00
|
|
|
*/
|
2022-12-09 01:38:11 +01:00
|
|
|
@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;
|
2022-12-09 00:29:00 +01:00
|
|
|
}else{
|
2022-12-09 01:38:11 +01:00
|
|
|
throw new RobotIllegalStateException("The Robot is turned off.");
|
2022-12-09 00:29:00 +01:00
|
|
|
}
|
2022-12-09 01:38:11 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
2022-12-09 10:45:51 +01:00
|
|
|
* @see RobotInstructions
|
2022-12-09 01:38:11 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public int[] think(int[] zahlen) throws RobotException {
|
|
|
|
return new int[0];
|
2022-12-09 00:29:00 +01:00
|
|
|
}
|
2022-12-09 10:45:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-12-09 00:29:00 +01:00
|
|
|
}
|