diff --git a/Main.java b/Main.java index 236b385..5ee4902 100644 --- a/Main.java +++ b/Main.java @@ -1,5 +1,4 @@ import domain.C3PO; -import domain.R2D2; import robot.exceptions.RobotException; public class Main { @@ -12,17 +11,8 @@ public class Main { //Herbert.triggerPowerSwitch(); //Gudrun.triggerPowerSwitch(); - try{ - Herbert.speak(input); - }catch(RobotException re){ - System.out.println(re); - } - try{ - Gudrun.think(input2); - }catch(RobotException re){ - System.out.println(re); - } + //System.out.println("Was neues ausgeben"); //just some testing diff --git a/domain/R2D2.java b/domain/R2D2.java index 4554b9b..368a61b 100644 --- a/domain/R2D2.java +++ b/domain/R2D2.java @@ -1,36 +1,57 @@ 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 + @@ -8,7 +12,35 @@ public class R2D2 extends RobotBasics { */ public R2D2(int id, String name){ super(id, name); - } @Override public int[] think(int[] zahlen) throws RobotException { - if(isPowerOn() == true){ - return selectionsSort.sorting(zahlen); - + if(isPowerOn()){ + return sorting(zahlen); }else{ - throw new RobotIllegalStateException(getName() + " is turned off."); + throw new RobotIllegalStateException(getName() + " is turned off!"); } } + public int[] sorting(int[] arr) { + //Selectionsort + int small; + for (int i = 0; i 1) { + for (int i = 1; i < arr.length; i++) { + result += "," + arr[i]; + } + } + } + return result; + */ - //Selectionsort... - Sorting selectionsSort = (int[] input) -> { - System.out.println("ich sortiere mit selection-Sort"); - - return input; - }; - -} +} \ No newline at end of file