Adding print option to UI
This commit is contained in:
@@ -83,6 +83,7 @@ public class AlgorithmTester{
|
|||||||
boolean bubble=false, selection=false, insertion=false;
|
boolean bubble=false, selection=false, insertion=false;
|
||||||
boolean quick=false, counting=false; //radix=false, merge=false;
|
boolean quick=false, counting=false; //radix=false, merge=false;
|
||||||
boolean ready=false;
|
boolean ready=false;
|
||||||
|
boolean print = false;
|
||||||
System.out.print("Please enter file name: ");
|
System.out.print("Please enter file name: ");
|
||||||
filename = sc.next();
|
filename = sc.next();
|
||||||
while(!ready){
|
while(!ready){
|
||||||
@@ -123,6 +124,19 @@ public class AlgorithmTester{
|
|||||||
System.out.println("Invalid input");
|
System.out.println("Invalid input");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try{
|
||||||
|
System.out.println("Print sorted list?");
|
||||||
|
System.out.println("1) Yes");
|
||||||
|
System.out.println("2) No");
|
||||||
|
input = sc.nextInt();
|
||||||
|
switch(input){
|
||||||
|
case 1 -> print=true;
|
||||||
|
case 2 -> print=false;
|
||||||
|
default -> System.out.println("Invalid input, defaulting to no");
|
||||||
|
}
|
||||||
|
}catch(InputMismatchException ex){
|
||||||
|
System.out.println("Invalid input, defaulting to no");
|
||||||
|
}
|
||||||
ArrayList<SortResult> results = new ArrayList<SortResult>();
|
ArrayList<SortResult> results = new ArrayList<SortResult>();
|
||||||
if(bubble){
|
if(bubble){
|
||||||
BubbleSorter bubSorter = new BubbleSorter(filename);
|
BubbleSorter bubSorter = new BubbleSorter(filename);
|
||||||
@@ -145,8 +159,10 @@ public class AlgorithmTester{
|
|||||||
results.add(qSorter.measuredSort());
|
results.add(qSorter.measuredSort());
|
||||||
}
|
}
|
||||||
for(SortResult e: results){
|
for(SortResult e: results){
|
||||||
for(int i: e.getSortedArray()){
|
if(print){
|
||||||
System.out.print(i+" ");
|
for(int i: e.getSortedArray()){
|
||||||
|
System.out.print(i+" ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
System.out.println("");
|
System.out.println("");
|
||||||
System.out.println(e.getSortType()+" sort took:");
|
System.out.println(e.getSortType()+" sort took:");
|
||||||
|
|||||||
Reference in New Issue
Block a user