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;
|
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
|
/**
|
||||||
|
* @return id of the robot
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
//returns name
|
|
||||||
|
/**
|
||||||
|
* @return name of the robot
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
//returns isPorwerOn true if it's false
|
|
||||||
|
/**
|
||||||
|
* @return isPorwerOn true if it's false
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void triggerPowerSwitch() {
|
public void triggerPowerSwitch() {
|
||||||
if(isPowerOn==false){
|
if(isPowerOn==false){
|
||||||
|
@ -32,18 +40,27 @@ public class C3PO implements Robot {
|
||||||
}
|
}
|
||||||
//tes test
|
//tes test
|
||||||
|
|
||||||
//returns isPowerOn
|
/**
|
||||||
|
* @return isPowerOn
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPowerOn() {
|
public boolean isPowerOn() {
|
||||||
return isPowerOn;
|
return isPowerOn;
|
||||||
}
|
}
|
||||||
//creating a RobotException
|
|
||||||
|
/**
|
||||||
|
* creating a RobotException getLastException
|
||||||
|
*/
|
||||||
@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
|
/**
|
||||||
|
* 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
|
@Override
|
||||||
public String speak(int[] zahlen) throws RobotException {
|
public String speak(int[] zahlen) throws RobotException {
|
||||||
|
|
||||||
|
@ -52,9 +69,14 @@ 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
|
* method to format the outcome
|
||||||
//each element of the Stream is separated by ;
|
* 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){
|
private String arrayFormatieren(int[] zahlen){
|
||||||
var ergebnis = Arrays.stream(zahlen)
|
var ergebnis = Arrays.stream(zahlen)
|
||||||
.boxed()
|
.boxed()
|
||||||
|
@ -63,7 +85,11 @@ public class C3PO implements Robot {
|
||||||
return ergebnis;
|
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
|
@Override
|
||||||
public int[] think(int[] zahlen) throws RobotException {
|
public int[] think(int[] zahlen) throws RobotException {
|
||||||
int n = zahlen.length;
|
int n = zahlen.length;
|
||||||
|
|
|
@ -6,7 +6,7 @@ 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;
|
||||||
|
|
|
@ -5,23 +5,31 @@ 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
|
/**
|
||||||
|
* @return id of the robot
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
//returns name
|
|
||||||
|
/**
|
||||||
|
* @return name of the robot
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
//returns isPorwerOn true if it's false
|
|
||||||
|
/**
|
||||||
|
* @return isPorwerOn true if it's false
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void triggerPowerSwitch() {
|
public void triggerPowerSwitch() {
|
||||||
if(isPowerOn==false){
|
if(isPowerOn==false){
|
||||||
|
@ -30,17 +38,28 @@ public class R2D2 implements Robot {
|
||||||
isPowerOn=false;
|
isPowerOn=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//returns isPowerOn
|
|
||||||
|
/**
|
||||||
|
* @return isPowerOn
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isPowerOn() {
|
public boolean isPowerOn() {
|
||||||
return isPowerOn;
|
return isPowerOn;
|
||||||
}
|
}
|
||||||
//creating a RobotException
|
|
||||||
|
/**
|
||||||
|
* creating a RobotException getLastException
|
||||||
|
*/
|
||||||
@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
|
|
||||||
|
/**
|
||||||
|
* 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
|
@Override
|
||||||
public String speak(int[] zahlen) throws RobotException {
|
public String speak(int[] zahlen) throws RobotException {
|
||||||
|
|
||||||
|
@ -48,9 +67,15 @@ 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 ,
|
* 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){
|
private String arrayFormatieren(int[] zahlen){
|
||||||
var ergebnis = Arrays.stream(zahlen)
|
var ergebnis = Arrays.stream(zahlen)
|
||||||
.boxed()
|
.boxed()
|
||||||
|
@ -58,7 +83,11 @@ 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
|
/**
|
||||||
|
* 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
|
@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