edited comments for C3PO and R2D2
parent
16947dde83
commit
8ee099ea6c
BIN
bin/C3PO.class
BIN
bin/C3PO.class
Binary file not shown.
BIN
bin/R2D2.class
BIN
bin/R2D2.class
Binary file not shown.
|
@ -5,23 +5,31 @@ 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
|
||||
/**
|
||||
* @return id of the robot
|
||||
*/
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
//returns name
|
||||
|
||||
/**
|
||||
* @return name of the robot
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
//returns isPorwerOn true if it's false
|
||||
|
||||
/**
|
||||
* @return isPorwerOn true if it's false
|
||||
*/
|
||||
@Override
|
||||
public void triggerPowerSwitch() {
|
||||
if(isPowerOn==false){
|
||||
|
@ -32,18 +40,27 @@ public class C3PO implements Robot {
|
|||
}
|
||||
//tes test
|
||||
|
||||
//returns isPowerOn
|
||||
/**
|
||||
* @return isPowerOn
|
||||
*/
|
||||
@Override
|
||||
public boolean isPowerOn() {
|
||||
return isPowerOn;
|
||||
}
|
||||
//creating a RobotException
|
||||
|
||||
/**
|
||||
* creating a RobotException getLastException
|
||||
*/
|
||||
@Override
|
||||
public RobotException getLastException() {
|
||||
return null;
|
||||
}
|
||||
|
||||
//speak method that returns the sorted and formated numbers from the array zahlen
|
||||
/**
|
||||
* speak method that returns the sorted and formated numbers from the array zahlen
|
||||
* @param int[] zahlen Array of numbers for sorting
|
||||
* @return sorted and formated numbers
|
||||
*/
|
||||
@Override
|
||||
public String speak(int[] zahlen) throws RobotException {
|
||||
|
||||
|
@ -52,9 +69,14 @@ 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 ;
|
||||
/**
|
||||
* method to format the outcome
|
||||
* 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 ","
|
||||
* @param int[] zahlen Array of numbers to sort
|
||||
* @return formated outcome
|
||||
*/
|
||||
private String arrayFormatieren(int[] zahlen){
|
||||
var ergebnis = Arrays.stream(zahlen)
|
||||
.boxed()
|
||||
|
@ -63,7 +85,11 @@ public class C3PO implements Robot {
|
|||
return ergebnis;
|
||||
}
|
||||
|
||||
//method that sorts the array zahlen with the Selectionsort-Algorithmin in descending order
|
||||
/**
|
||||
* method that sorts the array zahlen with the Selectionsort-Algorithmin in descending order
|
||||
* @param int[] zahlen Array of numbers for sorting
|
||||
* @return array of numbers in descending order
|
||||
*/
|
||||
@Override
|
||||
public int[] think(int[] zahlen) throws RobotException {
|
||||
int n = zahlen.length;
|
||||
|
|
|
@ -6,7 +6,7 @@ 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;
|
||||
|
|
|
@ -5,23 +5,31 @@ import java.util.Arrays;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
public class R2D2 implements Robot {
|
||||
//declaring
|
||||
|
||||
private int id;
|
||||
private String name;
|
||||
private boolean isPowerOn;
|
||||
|
||||
|
||||
//returns id
|
||||
/**
|
||||
* @return id of the robot
|
||||
*/
|
||||
@Override
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
//returns name
|
||||
|
||||
/**
|
||||
* @return name of the robot
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
//returns isPorwerOn true if it's false
|
||||
|
||||
/**
|
||||
* @return isPorwerOn true if it's false
|
||||
*/
|
||||
@Override
|
||||
public void triggerPowerSwitch() {
|
||||
if(isPowerOn==false){
|
||||
|
@ -30,17 +38,28 @@ public class R2D2 implements Robot {
|
|||
isPowerOn=false;
|
||||
}
|
||||
}
|
||||
//returns isPowerOn
|
||||
|
||||
/**
|
||||
* @return isPowerOn
|
||||
*/
|
||||
@Override
|
||||
public boolean isPowerOn() {
|
||||
return isPowerOn;
|
||||
}
|
||||
//creating a RobotException
|
||||
|
||||
/**
|
||||
* creating a RobotException getLastException
|
||||
*/
|
||||
@Override
|
||||
public RobotException getLastException() {
|
||||
return null;
|
||||
}
|
||||
//speak method that returns the sorted and formated numbers from the array zahlen
|
||||
|
||||
/**
|
||||
* speak method that returns the sorted and formated numbers from the array zahlen
|
||||
* @param int[] zahlen Array of numbers for sorting
|
||||
* @return sorted and formated numbers
|
||||
*/
|
||||
@Override
|
||||
public String speak(int[] zahlen) throws RobotException {
|
||||
|
||||
|
@ -48,9 +67,15 @@ 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 ,
|
||||
|
||||
/**
|
||||
* method to format the outcome
|
||||
* 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 ","
|
||||
* @param int[] zahlen Array of numbers to sort
|
||||
* @return formated outcome
|
||||
*/
|
||||
private String arrayFormatieren(int[] zahlen){
|
||||
var ergebnis = Arrays.stream(zahlen)
|
||||
.boxed()
|
||||
|
@ -58,7 +83,11 @@ public class R2D2 implements Robot {
|
|||
.collect(Collectors.joining(","));
|
||||
return ergebnis;
|
||||
}
|
||||
//method that sorts the array zahlen with the Selectionsort-Algorithmin in ascending order
|
||||
/**
|
||||
* method that sorts the array zahlen with the Selectionsort-Algorithmin in ascending order
|
||||
* @param int[] zahlen Array of numbers for sorting
|
||||
* @return array of numbers in ascending order
|
||||
*/
|
||||
@Override
|
||||
public int[] think(int[] zahlen) throws RobotException {
|
||||
int n = zahlen.length;
|
||||
|
|
Loading…
Reference in New Issue