Pr_robot_factory/domain/R2D2.java

37 lines
748 B
Java

package domain;
import robot.exceptions.RobotException;
import robot.exceptions.RobotIllegalStateException;
import robot.interfaces.Sorting;
public class R2D2 extends RobotBasics {
/**
* Constructor
* @param id> int
* @param name> String
*/
public R2D2(int id, String name){
super(id, name);
}
@Override
public int[] think(int[] zahlen) throws RobotException {
if(isPowerOn() == true){
return selectionsSort.sorting(zahlen);
}else{
throw new RobotIllegalStateException(getName() + " is turned off.");
}
}
//Selectionsort...
Sorting selectionsSort = (int[] input) -> {
System.out.println("ich sortiere mit selection-Sort");
return input;
};
}