refactor to use polymorphism

This commit is contained in:
2020-06-17 22:15:00 -05:00
parent fe9000267a
commit 5d9c8ebde6
14 changed files with 82 additions and 152 deletions

View File

@@ -177,7 +177,7 @@ public class AlgorithmTester{
for(SortResult e: results){
if(e!=null){
if(print){
for(int i: e.getSortedArray()){
for(int i: e.getSortedNumbers()){
System.out.print(i+" ");
}
System.out.print("\n");
@@ -245,7 +245,7 @@ public class AlgorithmTester{
}
boolean selection = sortingAlgoChoices[0];
boolean insertion = sortingAlgoChoices[1];
ArrayList<WordSortResult> results = new ArrayList<WordSortResult>();
ArrayList<SortResult> results = new ArrayList<SortResult>();
if(selection){
WordSelectionSorter selSorter = new WordSelectionSorter(reader);
results.add(selSorter.measuredSort());
@@ -254,15 +254,15 @@ public class AlgorithmTester{
WordInsertionSorter inSorter = new WordInsertionSorter(reader);
results.add(inSorter.measuredSort());
}
for(WordSortResult e: results){
for(SortResult e: results){
if(e!=null){
if(print){
for(String i: e.getSortedArray()){
for(String i: e.getSortedWords()){
System.out.print(i+" ");
}
System.out.print("\n");
}
System.out.println("\n"+e.getSortType()+" of "+e.getSortCount()+" words from "+e.getMin()+" to "+e.getMax()+" took:");
System.out.println("\n"+e.getSortType()+" of "+e.getSortCount()+" words from "+e.getFirst()+" to "+e.getLast()+" took:");
System.out.println(e.getComparisonsUsed()+" comparisons");
System.out.println(e.getWritesUsed()+" write operations");
System.out.println(e.getTimeUsed()+" milliseconds");