comments
parent
dabe1dda0f
commit
16947dde83
BIN
bin/C3PO.class
BIN
bin/C3PO.class
Binary file not shown.
BIN
bin/Nexus6.class
BIN
bin/Nexus6.class
Binary file not shown.
BIN
bin/R2D2.class
BIN
bin/R2D2.class
Binary file not shown.
|
@ -5,22 +5,23 @@ import java.util.Arrays;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class C3PO implements Robot {
|
||||
//declaring
|
||||
private int id;
|
||||
private String name;
|
||||
private boolean isPowerOn;
|
||||
|
||||
|
||||
|
||||
//returns id
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
//returns name
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
//returns isPorwerOn true if it's false
|
||||
@Override
|
||||
public void triggerPowerSwitch() {
|
||||
if(isPowerOn==false){
|
||||
|
@ -30,17 +31,19 @@ public class C3PO implements Robot {
|
|||
}
|
||||
}
|
||||
//tes test
|
||||
|
||||
|
||||
//returns isPowerOn
|
||||
@Override
|
||||
public boolean isPowerOn() {
|
||||
return isPowerOn;
|
||||
}
|
||||
|
||||
//creating a RobotException
|
||||
@Override
|
||||
public RobotException getLastException() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
//speak method that returns the sorted and formated numbers from the array zahlen
|
||||
@Override
|
||||
public String speak(int[] zahlen) throws RobotException {
|
||||
|
||||
|
@ -48,7 +51,10 @@ public class C3PO implements Robot {
|
|||
|
||||
return arrayFormatieren(sortiert);
|
||||
}
|
||||
|
||||
|
||||
//method to format the result
|
||||
//Returns a Stream consisting of the elements of this stream,each boxed to an Integer and maps it into a String
|
||||
//each element of the Stream is separated by ;
|
||||
private String arrayFormatieren(int[] zahlen){
|
||||
var ergebnis = Arrays.stream(zahlen)
|
||||
.boxed()
|
||||
|
@ -56,6 +62,8 @@ public class C3PO implements Robot {
|
|||
.collect(Collectors.joining(";"));
|
||||
return ergebnis;
|
||||
}
|
||||
|
||||
//method that sorts the array zahlen with the Selectionsort-Algorithmin in descending order
|
||||
@Override
|
||||
public int[] think(int[] zahlen) throws RobotException {
|
||||
int n = zahlen.length;
|
||||
|
|
|
@ -6,55 +6,55 @@ import java.util.Arrays;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class Nexus6 implements Robot {
|
||||
|
||||
//declaring and initializing
|
||||
private int id = 19281982;
|
||||
private String name = "pris";
|
||||
private boolean isPowerOn = false;
|
||||
|
||||
|
||||
//creating an instance of Nexus
|
||||
private static Nexus6 instance = new Nexus6();
|
||||
|
||||
//constructor of Nexus
|
||||
private Nexus6() {
|
||||
}
|
||||
|
||||
|
||||
//instance of Nexus is null
|
||||
public static Nexus6 getInstance() {
|
||||
if (instance == null)
|
||||
instance = new Nexus6();
|
||||
return instance;
|
||||
}
|
||||
|
||||
|
||||
//returns id
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
//returns name
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
//isPowerOn must be false
|
||||
@Override
|
||||
public void triggerPowerSwitch() {
|
||||
if(isPowerOn==false){
|
||||
isPowerOn=true;
|
||||
isPowerOn=false;
|
||||
}else{
|
||||
isPowerOn=false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//retruns isPowerOn
|
||||
@Override
|
||||
public boolean isPowerOn() {
|
||||
return isPowerOn;
|
||||
}
|
||||
|
||||
//creating a RobotException
|
||||
@Override
|
||||
public RobotException getLastException() {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String speak(int[] zahlen) /*throws RobotIllegalStateException */{
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class Nexus6 implements Robot {
|
|||
|
||||
return arrayFormatieren(sortiert);
|
||||
}
|
||||
|
||||
|
||||
private String arrayFormatieren(int[] zahlen){
|
||||
var ergebnis = Arrays.stream(zahlen)
|
||||
.boxed()
|
||||
|
|
|
@ -5,22 +5,23 @@ import java.util.Arrays;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class R2D2 implements Robot {
|
||||
private int id;
|
||||
//declaring
|
||||
private int id;
|
||||
private String name;
|
||||
private boolean isPowerOn;
|
||||
|
||||
|
||||
|
||||
//returns id
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
//returns name
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
//returns isPorwerOn true if it's false
|
||||
@Override
|
||||
public void triggerPowerSwitch() {
|
||||
if(isPowerOn==false){
|
||||
|
@ -29,17 +30,17 @@ public class R2D2 implements Robot {
|
|||
isPowerOn=false;
|
||||
}
|
||||
}
|
||||
|
||||
//returns isPowerOn
|
||||
@Override
|
||||
public boolean isPowerOn() {
|
||||
return isPowerOn;
|
||||
}
|
||||
|
||||
//creating a RobotException
|
||||
@Override
|
||||
public RobotException getLastException() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//speak method that returns the sorted and formated numbers from the array zahlen
|
||||
@Override
|
||||
public String speak(int[] zahlen) throws RobotException {
|
||||
|
||||
|
@ -47,7 +48,9 @@ public class R2D2 implements Robot {
|
|||
|
||||
return arrayFormatieren(sortiert);
|
||||
}
|
||||
|
||||
//method to format the result
|
||||
//Returns a Stream consisting of the elements of this stream,each boxed to an Integer and maps it into a String
|
||||
//each element of the Stream is separated by ,
|
||||
private String arrayFormatieren(int[] zahlen){
|
||||
var ergebnis = Arrays.stream(zahlen)
|
||||
.boxed()
|
||||
|
@ -55,6 +58,7 @@ public class R2D2 implements Robot {
|
|||
.collect(Collectors.joining(","));
|
||||
return ergebnis;
|
||||
}
|
||||
//method that sorts the array zahlen with the Selectionsort-Algorithmin in ascending order
|
||||
@Override
|
||||
public int[] think(int[] zahlen) throws RobotException {
|
||||
int n = zahlen.length;
|
||||
|
|
Loading…
Reference in New Issue