diff --git a/src/C3PO.java b/src/C3PO.java index 08d4f75..38fe1ae 100644 --- a/src/C3PO.java +++ b/src/C3PO.java @@ -61,7 +61,7 @@ public class C3PO implements Robot { for (int i = 1; i < n; ++i) { int key = zahlen[i]; int j = i - 1; - while (j >= 0 && zahlen[j] > key) { + while (j >= 0 && zahlen[j] < key) { zahlen[j + 1] = zahlen[j]; j = j - 1; } diff --git a/src/Nexus6.java b/src/Nexus6.java index ff6ef73..1338ab1 100644 --- a/src/Nexus6.java +++ b/src/Nexus6.java @@ -1,21 +1,23 @@ import tpe.exceptions.roboter.Robot; import tpe.exceptions.roboter.exceptions.RobotException; +import tpe.exceptions.roboter.exceptions.RobotIllegalStateException; import java.util.Arrays; import java.util.stream.Collectors; public class Nexus6 implements Robot { - + + private int id = 19281982; + private String name = "pris"; + private boolean isPowerOn = false; + + private static Nexus6 instance = new Nexus6(); - private int id; - private String name; - private boolean isPowerOn; - private Nexus6() { - } + public static Nexus6 getInstance() { if (instance == null) instance = new Nexus6(); @@ -25,12 +27,12 @@ public class Nexus6 implements Robot { @Override public int getId() { - return 19281982; + return id; } @Override public String getName() { - return "pris"; + return name; } @Override @@ -41,6 +43,7 @@ public class Nexus6 implements Robot { isPowerOn=false; } } + @Override public boolean isPowerOn() { @@ -53,7 +56,7 @@ public class Nexus6 implements Robot { } @Override - public String speak(int[] zahlen) throws RobotException { + public String speak(int[] zahlen) /*throws RobotIllegalStateException */{ var sortiert = think(zahlen); @@ -68,7 +71,7 @@ public class Nexus6 implements Robot { return ergebnis; } @Override - public int[] think(int[] zahlen) throws RobotException { + public int[] think(int[] zahlen) /*throws RobotIllegalStateException*/ { int n = zahlen.length; for (int i = 1; i < n; ++i) { int key = zahlen[i]; @@ -81,4 +84,7 @@ public class Nexus6 implements Robot { } return zahlen; } + + + } diff --git a/src/R2D2.java b/src/R2D2.java index d71c5d9..502f6fa 100644 --- a/src/R2D2.java +++ b/src/R2D2.java @@ -61,7 +61,7 @@ public class R2D2 implements Robot { for (int i = 1; i < n; ++i) { int key = zahlen[i]; int j = i - 1; - while (j >= 0 && zahlen[j] < key) { + while (j >= 0 && zahlen[j] > key) { zahlen[j + 1] = zahlen[j]; j = j - 1; }