generated from hummel/Bank-System
70 lines
1.3 KiB
Java
70 lines
1.3 KiB
Java
package tpe.exceptions.roboter;
|
|
|
|
//import java.util.*;
|
|
|
|
import tpe.exceptions.RobotException;
|
|
import tpe.exceptions.RobotIllegalStateException;
|
|
import tpe.exceptions.RobotMagicValueException;
|
|
|
|
public class C3PO extends Robots{
|
|
|
|
RobotType robotType;
|
|
// private RobotException lastException;
|
|
// private String name;
|
|
// private boolean powerSwitch;
|
|
private int id;
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
public C3PO(String name, int id) {
|
|
super(name);
|
|
this.id = id;
|
|
this.name = name;
|
|
robotType = RobotType.C3PO;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public int[] think(int[] zahlen) throws RobotIllegalStateException, RobotMagicValueException {
|
|
if(!isPowerOn())
|
|
{
|
|
throw new RobotIllegalStateException("Der Roboter ist ausgeschaltet!", this.getName());
|
|
}
|
|
else if(checkRobotMagicValueException(zahlen)==true)
|
|
{
|
|
throw new RobotMagicValueException("Zahl 42 kann nicht verarbeitet werden!",this.getName());
|
|
}
|
|
else {
|
|
int z;
|
|
|
|
for (int i = 1; i < zahlen.length; i++) {
|
|
z = zahlen[i];
|
|
int k = i;
|
|
|
|
while (k > 0 && zahlen[k - 1] < z) {
|
|
zahlen[k] = zahlen[k - 1];
|
|
k--;
|
|
}
|
|
zahlen[k] = z;
|
|
}
|
|
}
|
|
|
|
return zahlen;
|
|
}
|
|
|
|
|
|
public RobotType getRobotType() {
|
|
return this.robotType;
|
|
}
|
|
|
|
@Override
|
|
public int getId() {
|
|
|
|
return id;
|
|
}
|
|
|
|
}
|