error catching
This commit is contained in:
@@ -68,12 +68,18 @@ abstract class Sorter {
|
||||
* @return returns a SortResult object with the name of the sorting algorithm used, the sorted array of numbers, the number of comparisons used to sort, and the number of writes to arrays used to sort
|
||||
*/
|
||||
public SortResult measuredSort(){
|
||||
Instant start = Instant.now();
|
||||
this.sort();
|
||||
Instant end = Instant.now();
|
||||
Duration time = Duration.between(start,end);
|
||||
SortResult output = new SortResult(sortType, numbers, comparisonsUsed, writesUsed, time);
|
||||
return output;
|
||||
if(numbers.length!=0){
|
||||
Instant start = Instant.now();
|
||||
this.sort();
|
||||
Instant end = Instant.now();
|
||||
Duration time = Duration.between(start,end);
|
||||
SortResult output = new SortResult(sortType, numbers, comparisonsUsed, writesUsed, time);
|
||||
return output;
|
||||
}
|
||||
else{
|
||||
System.out.println("Nothing to sort using "+sortType);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user