added comment for think method

main
Stefan 2022-12-25 14:07:10 +01:00
parent ae17a3013e
commit 58cac3d48a
1 changed files with 9 additions and 2 deletions

View File

@ -22,9 +22,16 @@ public class R2D2 extends StarWarsRobot {
return 0 <= id && id <= 9999;
}
/**
* R2D2 think method sorts numbers with selection sort
* @param numbers integer numbers for sorting
* @return arrayToSort integer array with numbers sorted in ascending order
* @throws RobotException
* @throws RobotMagicValueException
*/
@Override
public int[] think(int[] zahlen) throws RobotException, RobotMagicValueException {
int[] arrayToSort = zahlen.clone();
public int[] think(int[] numbers) throws RobotException, RobotMagicValueException {
int[] arrayToSort = numbers.clone();
for (int i = 0; i < arrayToSort.length; i++) {
if (arrayToSort[i] == MAGIC_NUMBER) {
throw new RobotMagicValueException(String.format("Appearance of Magic Number: %d", MAGIC_NUMBER), this);