Pr_robot_factory/domain/RobotBasics.java

74 lines
1.2 KiB
Java
Raw Normal View History

2022-12-09 00:29:00 +01:00
package domain;
import robot.exceptions.RobotException;
import robot.exceptions.RobotIllegalStateException;
import robot.interfaces.Robot;
2022-12-14 09:54:18 +01:00
import java.util.Arrays;
public abstract class RobotBasics implements Robot {
2022-12-09 00:29:00 +01:00
private int id;
private String name;
private boolean power;
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() {
if(power){
power = false;
}else{
power = true;
}
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;
}
public boolean checkArray(int[] input){
for(int x: input){
if(x == 42){
return true;
}
2022-12-09 00:29:00 +01:00
}
return false;
2022-12-14 09:54:18 +01:00
}
2022-12-09 00:29:00 +01:00
}