2022-12-09 00:29:00 +01:00
|
|
|
package domain;
|
|
|
|
|
2022-12-09 01:38:11 +01:00
|
|
|
import roboter.exceptions.RobotException;
|
|
|
|
import roboter.exceptions.RobotIllegalStateException;
|
|
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
* @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() {
|
2022-12-09 01:38:11 +01:00
|
|
|
if(power == false){
|
|
|
|
power = true;
|
|
|
|
}else{
|
|
|
|
power = false;
|
|
|
|
}
|
2022-12-09 00:29:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see domain.RobotControl
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean isPowerOn() {
|
|
|
|
return power;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-12-09 01:38:11 +01:00
|
|
|
* @see roboter.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
|
|
|
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @see roboter.RobotInstructions
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public int[] think(int[] zahlen) throws RobotException {
|
|
|
|
return new int[0];
|
2022-12-09 00:29:00 +01:00
|
|
|
}
|
|
|
|
}
|