Pr_robot_factory/domain/C3PO.java

35 lines
901 B
Java
Raw Normal View History

2022-12-08 14:58:44 +01:00
package domain;
2022-12-14 09:48:20 +01:00
import org.junit.jupiter.params.shadow.com.univocity.parsers.common.fields.ColumnMapping;
import robot.interfaces.Sorting;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.atomic.AtomicReference;
public class C3PO extends RobotBasics implements Sorting {
public C3PO(int id, String name){
super(id, name);
}
2022-12-14 09:48:20 +01:00
//@Override
public String sorting(int[] arr) {
//Insertionsort
for(int i=1;i<arr.length;i++){
int b = i-1;
int key = arr[i];
while(b>=0 && arr[b]>key) arr[b+1] = arr[b--];
arr[b+1] = key;
}
//Writing all values of the array into a String
String result = "" + arr[0];
if(arr.length > 1) {
for (int i = 1; i < arr.length; i++) {
result += ";" + arr[i];
}
}
return result;
}
2022-12-08 14:58:44 +01:00
}