rename to distinguish btw number and word sorters
This commit is contained in:
24
Sorting/NumberBubbleSorter.java
Normal file
24
Sorting/NumberBubbleSorter.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package Sorting;
|
||||
|
||||
public class NumberBubbleSorter extends NumberSorter{
|
||||
//a class to sort arrays of numbers using bubble sort
|
||||
|
||||
public NumberBubbleSorter(RandomNumberFileReader reader){
|
||||
super("bubble sort", reader);
|
||||
}
|
||||
|
||||
void sort(){
|
||||
|
||||
boolean usedSwap;
|
||||
do{
|
||||
usedSwap=false;
|
||||
for(int i=0;i<numbers.length-1;i++){
|
||||
if(compare(numbers[i],numbers[i+1])>0){
|
||||
swap(i,i+1);
|
||||
usedSwap=true;
|
||||
}
|
||||
}
|
||||
}while(usedSwap);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user