From 8ee099ea6c44fc1a759406abe8acf456b86aac94 Mon Sep 17 00:00:00 2001 From: Eline Date: Mon, 9 Jan 2023 14:26:59 +0100 Subject: [PATCH] edited comments for C3PO and R2D2 --- bin/C3PO.class | Bin 2683 -> 2683 bytes bin/R2D2.class | Bin 2683 -> 2683 bytes src/C3PO.java | 48 ++++++++++++++++++++++++++++++++++----------- src/Nexus6.java | 2 +- src/R2D2.java | 51 +++++++++++++++++++++++++++++++++++++----------- 5 files changed, 78 insertions(+), 23 deletions(-) diff --git a/bin/C3PO.class b/bin/C3PO.class index 5180443046a0f2ca7aeffe224979ae092c32b228..174c0db80b1cde84d9ec8d7bca9970c6695c9183 100644 GIT binary patch delta 143 zcmew@@>^tsGdrX3B2!qDtd+ctE24GcI z94d?!ljAvjS)Cc!7+fcB6zN)4=xivI(3N$Fu#KV`5j#Te|O-)w~^tsGdrX3B2!qDtd+ctE`e0R7 z94d_FljAvjS)CZz7+fZA8=VU{GWTnQX#2T{D(}nIVpW pgCU-Qmmz^ch#`?dlp%>ho*|h*3CK2JNM*19$~!QmPyWK$4gf4X8#Vv{ delta 143 zcmW;DOAf(M7(n53<8f~jBBj^FtE7o^ghWzm(khJz3ox<+doZ$qe_$JI$STY_(U^UM za|*BUUYS;|+_ja9o~mxCliNenr@??0Lp*%>=v)Q=DmH-%YsMo?$|T6vLJ#8Etl0_Ke7xl%8`azm$Zde4WP+zseZ% diff --git a/src/C3PO.java b/src/C3PO.java index 9196d28..e915b08 100644 --- a/src/C3PO.java +++ b/src/C3PO.java @@ -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; diff --git a/src/Nexus6.java b/src/Nexus6.java index 3a4f8bc..5906c64 100644 --- a/src/Nexus6.java +++ b/src/Nexus6.java @@ -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; diff --git a/src/R2D2.java b/src/R2D2.java index 12597aa..62e644b 100644 --- a/src/R2D2.java +++ b/src/R2D2.java @@ -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;