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;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class C3PO implements Robot {
|
public class C3PO implements Robot {
|
||||||
|
//declaring
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
private boolean isPowerOn;
|
private boolean isPowerOn;
|
||||||
|
|
||||||
|
|
||||||
|
//returns id
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
//returns name
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
//returns isPorwerOn true if it's false
|
||||||
@Override
|
@Override
|
||||||
public void triggerPowerSwitch() {
|
public void triggerPowerSwitch() {
|
||||||
if(isPowerOn==false){
|
if(isPowerOn==false){
|
||||||
|
@ -31,16 +32,18 @@ public class C3PO implements Robot {
|
||||||
}
|
}
|
||||||
//tes test
|
//tes test
|
||||||
|
|
||||||
|
//returns isPowerOn
|
||||||
@Override
|
@Override
|
||||||
public boolean isPowerOn() {
|
public boolean isPowerOn() {
|
||||||
return isPowerOn;
|
return isPowerOn;
|
||||||
}
|
}
|
||||||
|
//creating a RobotException
|
||||||
@Override
|
@Override
|
||||||
public RobotException getLastException() {
|
public RobotException getLastException() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//speak method that returns the sorted and formated numbers from the array zahlen
|
||||||
@Override
|
@Override
|
||||||
public String speak(int[] zahlen) throws RobotException {
|
public String speak(int[] zahlen) throws RobotException {
|
||||||
|
|
||||||
|
@ -49,6 +52,9 @@ public class C3PO implements Robot {
|
||||||
return arrayFormatieren(sortiert);
|
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){
|
private String arrayFormatieren(int[] zahlen){
|
||||||
var ergebnis = Arrays.stream(zahlen)
|
var ergebnis = Arrays.stream(zahlen)
|
||||||
.boxed()
|
.boxed()
|
||||||
|
@ -56,6 +62,8 @@ public class C3PO implements Robot {
|
||||||
.collect(Collectors.joining(";"));
|
.collect(Collectors.joining(";"));
|
||||||
return ergebnis;
|
return ergebnis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//method that sorts the array zahlen with the Selectionsort-Algorithmin in descending order
|
||||||
@Override
|
@Override
|
||||||
public int[] think(int[] zahlen) throws RobotException {
|
public int[] think(int[] zahlen) throws RobotException {
|
||||||
int n = zahlen.length;
|
int n = zahlen.length;
|
||||||
|
|
|
@ -6,50 +6,50 @@ import java.util.Arrays;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Nexus6 implements Robot {
|
public class Nexus6 implements Robot {
|
||||||
|
//declaring and initializing
|
||||||
private int id = 19281982;
|
private int id = 19281982;
|
||||||
private String name = "pris";
|
private String name = "pris";
|
||||||
private boolean isPowerOn = false;
|
private boolean isPowerOn = false;
|
||||||
|
|
||||||
|
//creating an instance of Nexus
|
||||||
private static Nexus6 instance = new Nexus6();
|
private static Nexus6 instance = new Nexus6();
|
||||||
|
//constructor of Nexus
|
||||||
private Nexus6() {
|
private Nexus6() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//instance of Nexus is null
|
||||||
public static Nexus6 getInstance() {
|
public static Nexus6 getInstance() {
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
instance = new Nexus6();
|
instance = new Nexus6();
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//returns id
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
//returns name
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
//isPowerOn must be false
|
||||||
@Override
|
@Override
|
||||||
public void triggerPowerSwitch() {
|
public void triggerPowerSwitch() {
|
||||||
if(isPowerOn==false){
|
if(isPowerOn==false){
|
||||||
isPowerOn=true;
|
isPowerOn=false;
|
||||||
}else{
|
}else{
|
||||||
isPowerOn=false;
|
isPowerOn=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//retruns isPowerOn
|
||||||
@Override
|
@Override
|
||||||
public boolean isPowerOn() {
|
public boolean isPowerOn() {
|
||||||
return isPowerOn;
|
return isPowerOn;
|
||||||
}
|
}
|
||||||
|
//creating a RobotException
|
||||||
@Override
|
@Override
|
||||||
public RobotException getLastException() {
|
public RobotException getLastException() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -5,22 +5,23 @@ import java.util.Arrays;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class R2D2 implements Robot {
|
public class R2D2 implements Robot {
|
||||||
|
//declaring
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
private boolean isPowerOn;
|
private boolean isPowerOn;
|
||||||
|
|
||||||
|
|
||||||
|
//returns id
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
//returns name
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
//returns isPorwerOn true if it's false
|
||||||
@Override
|
@Override
|
||||||
public void triggerPowerSwitch() {
|
public void triggerPowerSwitch() {
|
||||||
if(isPowerOn==false){
|
if(isPowerOn==false){
|
||||||
|
@ -29,17 +30,17 @@ public class R2D2 implements Robot {
|
||||||
isPowerOn=false;
|
isPowerOn=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//returns isPowerOn
|
||||||
@Override
|
@Override
|
||||||
public boolean isPowerOn() {
|
public boolean isPowerOn() {
|
||||||
return isPowerOn;
|
return isPowerOn;
|
||||||
}
|
}
|
||||||
|
//creating a RobotException
|
||||||
@Override
|
@Override
|
||||||
public RobotException getLastException() {
|
public RobotException getLastException() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
//speak method that returns the sorted and formated numbers from the array zahlen
|
||||||
@Override
|
@Override
|
||||||
public String speak(int[] zahlen) throws RobotException {
|
public String speak(int[] zahlen) throws RobotException {
|
||||||
|
|
||||||
|
@ -47,7 +48,9 @@ public class R2D2 implements Robot {
|
||||||
|
|
||||||
return arrayFormatieren(sortiert);
|
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){
|
private String arrayFormatieren(int[] zahlen){
|
||||||
var ergebnis = Arrays.stream(zahlen)
|
var ergebnis = Arrays.stream(zahlen)
|
||||||
.boxed()
|
.boxed()
|
||||||
|
@ -55,6 +58,7 @@ public class R2D2 implements Robot {
|
||||||
.collect(Collectors.joining(","));
|
.collect(Collectors.joining(","));
|
||||||
return ergebnis;
|
return ergebnis;
|
||||||
}
|
}
|
||||||
|
//method that sorts the array zahlen with the Selectionsort-Algorithmin in ascending order
|
||||||
@Override
|
@Override
|
||||||
public int[] think(int[] zahlen) throws RobotException {
|
public int[] think(int[] zahlen) throws RobotException {
|
||||||
int n = zahlen.length;
|
int n = zahlen.length;
|
||||||
|
|
Loading…
Reference in New Issue