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;
|
2022-12-14 09:54:18 +01:00
|
|
|
|
|
|
|
import java.util.Arrays;
|
2022-12-09 10:45:51 +01:00
|
|
|
|
2022-12-09 01:38:11 +01:00
|
|
|
|
2022-12-20 12:03:41 +01:00
|
|
|
public abstract 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-14 09:54:18 +01:00
|
|
|
* @see robot.interfaces.RobotControl;
|
2022-12-09 00:29:00 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public int getId() {
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-12-14 09:54:18 +01:00
|
|
|
* @see robot.interfaces.RobotControl;
|
2022-12-09 00:29:00 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-12-14 09:54:18 +01:00
|
|
|
* @see robot.interfaces.RobotControl;
|
2022-12-09 00:29:00 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public void triggerPowerSwitch() {
|
2022-12-20 12:03:41 +01:00
|
|
|
if(power){
|
2022-12-09 01:38:11 +01:00
|
|
|
power = false;
|
2022-12-20 12:03:41 +01:00
|
|
|
}else{
|
|
|
|
power = true;
|
2022-12-09 01:38:11 +01:00
|
|
|
}
|
2022-12-09 00:29:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-12-14 09:54:18 +01:00
|
|
|
* @see robot.interfaces.RobotControl;
|
2022-12-09 00:29:00 +01:00
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public boolean isPowerOn() {
|
|
|
|
return power;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-12-14 09:54:18 +01:00
|
|
|
* @see robot.interfaces.RobotControl;
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
public RobotException getLastException() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-12-20 12:03:41 +01:00
|
|
|
public boolean checkArray(int[] input){
|
|
|
|
for(int x: input){
|
|
|
|
if(x == 42){
|
|
|
|
return true;
|
|
|
|
}
|
2022-12-09 00:29:00 +01:00
|
|
|
}
|
2022-12-20 12:03:41 +01:00
|
|
|
return false;
|
2022-12-14 09:54:18 +01:00
|
|
|
}
|
2022-12-09 10:45:51 +01:00
|
|
|
|
2022-12-09 00:29:00 +01:00
|
|
|
}
|