85 lines
1.9 KiB
Java
85 lines
1.9 KiB
Java
package Domäne;
|
|
|
|
import tpe.exceptions.roboter.exceptions.RobotException;
|
|
import tpe.exceptions.roboter.exceptions.RobotIllegalStateException;
|
|
/**
|
|
* Die Klasse Nexus6 hat ein einziges Objekt namens Pris
|
|
* Pris ist defekt und hat immer die gleiche id:19281982
|
|
*/
|
|
public class Nexus6 extends Roboter {
|
|
|
|
private String name;
|
|
private int id;
|
|
private static Nexus6 PRIS;
|
|
private RobotType robotType;
|
|
|
|
private Nexus6() {
|
|
super("Pris");
|
|
this.id = 19_281_982;
|
|
robotType = RobotType.NEXUS6;
|
|
|
|
}
|
|
/**
|
|
* Falls es noch kein Objekt gibt wird eins erzeugt.
|
|
* Besteht jedoch schon ein Objekt, so wird das Objekt zurückgegeben
|
|
* und kein neues erzeugt.
|
|
* @return Pris
|
|
*/
|
|
public static Nexus6 getInstance() {
|
|
if (PRIS == null) {
|
|
PRIS = new Nexus6();
|
|
|
|
}
|
|
return PRIS;
|
|
}
|
|
/**
|
|
* @see RobotControl#triggerPowerSwitch()
|
|
* hier bleibt jedoch power immer auf false
|
|
*/
|
|
@Override
|
|
public void triggerPowerSwitch() {
|
|
power = false;
|
|
}
|
|
/**
|
|
* @see RobotControl#getID(int)
|
|
* gibt immer die gleiche id zurück: 19281982
|
|
*/
|
|
@Override
|
|
public int getId() {
|
|
return id;
|
|
}
|
|
|
|
/**
|
|
* @see RobotInstructions#speak(String)
|
|
* @throws RobotIllegalStateException
|
|
* Methode soll Fehler ausgeben, da der Roboter nicht Funktioniert.
|
|
*/
|
|
@Override
|
|
public String speak(int[] zahlen) throws RobotException {
|
|
fehler = new RobotIllegalStateException("Roboter ausgeschaltet und Defekt!", this.name);
|
|
throw fehler;
|
|
|
|
}
|
|
|
|
/**
|
|
* @see RoboInstructions
|
|
* @throws RobotIllegalStateException
|
|
* Methode soll Fehler ausgeben, da der Roboter nicht Funktioniert.
|
|
*/
|
|
@Override
|
|
public int[] think(int[] zahlen) throws RobotException {
|
|
fehler = new RobotIllegalStateException("Roboter ausgeschaltet und Defekt!", this.name);
|
|
throw fehler;
|
|
|
|
}
|
|
/**
|
|
* @see Roboter#getRobotType(robotType)
|
|
*/
|
|
@Override
|
|
public RobotType getRobotType() {
|
|
|
|
return this.robotType;
|
|
}
|
|
|
|
}
|