abstract Superclass for Robot
parent
4e569529f5
commit
c5c665a9f3
|
@ -0,0 +1,50 @@
|
|||
package domain;
|
||||
|
||||
public abstract class RobotBasics implements Robot {
|
||||
private int id;
|
||||
private String name;
|
||||
private boolean power;
|
||||
|
||||
/**
|
||||
* @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() {
|
||||
toggle(power);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see domain.RobotControl
|
||||
*/
|
||||
@Override
|
||||
public boolean isPowerOn() {
|
||||
return power;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see domain.RobotControl
|
||||
*/
|
||||
public static void toggle(boolean b){
|
||||
if(b == false){
|
||||
b = true;
|
||||
}else{
|
||||
b = false;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue