diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..0cbf9cd
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ae3c172
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/.project b/.project
new file mode 100644
index 0000000..bf10708
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ Robot
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/src/C3PO.java b/src/C3PO.java
index dc5b72c..fdc0ce8 100644
--- a/src/C3PO.java
+++ b/src/C3PO.java
@@ -62,7 +62,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
new file mode 100644
index 0000000..1338ab1
--- /dev/null
+++ b/src/Nexus6.java
@@ -0,0 +1,90 @@
+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 Nexus6() {
+ }
+
+
+ public static Nexus6 getInstance() {
+ if (instance == null)
+ instance = new Nexus6();
+ return instance;
+ }
+
+
+ @Override
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void triggerPowerSwitch() {
+ if(isPowerOn==false){
+ isPowerOn=true;
+ }else{
+ isPowerOn=false;
+ }
+ }
+
+
+ @Override
+ public boolean isPowerOn() {
+ return isPowerOn;
+ }
+
+ @Override
+ public RobotException getLastException() {
+ return null;
+ }
+
+ @Override
+ public String speak(int[] zahlen) /*throws RobotIllegalStateException */{
+
+ var sortiert = think(zahlen);
+
+ return arrayFormatieren(sortiert);
+ }
+
+ private String arrayFormatieren(int[] zahlen){
+ var ergebnis = Arrays.stream(zahlen)
+ .boxed()
+ .map(String::valueOf)
+ .collect(Collectors.joining(","));
+ return ergebnis;
+ }
+ @Override
+ public int[] think(int[] zahlen) /*throws RobotIllegalStateException*/ {
+ int n = zahlen.length;
+ for (int i = 1; i < n; ++i) {
+ int key = zahlen[i];
+ int j = i - 1;
+ while (j >= 0 && zahlen[j] < key) {
+ zahlen[j + 1] = zahlen[j];
+ j = j - 1;
+ }
+ zahlen[j + 1] = key;
+ }
+ return zahlen;
+ }
+
+
+
+}
diff --git a/src/R2D2.java b/src/R2D2.java
new file mode 100644
index 0000000..502f6fa
--- /dev/null
+++ b/src/R2D2.java
@@ -0,0 +1,72 @@
+import tpe.exceptions.roboter.Robot;
+import tpe.exceptions.roboter.exceptions.RobotException;
+
+import java.util.Arrays;
+import java.util.stream.Collectors;
+
+public class R2D2 implements Robot {
+ private int id;
+ private String name;
+ private boolean isPowerOn;
+
+
+
+ @Override
+ public int getId() {
+ return id;
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public void triggerPowerSwitch() {
+ if(isPowerOn==false){
+ isPowerOn=true;
+ }else{
+ isPowerOn=false;
+ }
+ }
+
+ @Override
+ public boolean isPowerOn() {
+ return isPowerOn;
+ }
+
+ @Override
+ public RobotException getLastException() {
+ return null;
+ }
+
+ @Override
+ public String speak(int[] zahlen) throws RobotException {
+
+ var sortiert = think(zahlen);
+
+ return arrayFormatieren(sortiert);
+ }
+
+ private String arrayFormatieren(int[] zahlen){
+ var ergebnis = Arrays.stream(zahlen)
+ .boxed()
+ .map(String::valueOf)
+ .collect(Collectors.joining(","));
+ return ergebnis;
+ }
+ @Override
+ public int[] think(int[] zahlen) throws RobotException {
+ int n = zahlen.length;
+ for (int i = 1; i < n; ++i) {
+ int key = zahlen[i];
+ int j = i - 1;
+ while (j >= 0 && zahlen[j] > key) {
+ zahlen[j + 1] = zahlen[j];
+ j = j - 1;
+ }
+ zahlen[j + 1] = key;
+ }
+ return zahlen;
+ }
+}