Skip to content

Commit

Permalink
Change SortingAlgorithm to be an abstract class instead of an interface
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrovgs committed Feb 1, 2015
1 parent 8e3bbee commit b5291a0
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,19 @@
*
* @author Pedro Vicente Gómez Sánchez.
*/
public interface SortingAlgorithm {
public abstract class SortingAlgorithm {

void sort(int[] numbers);
public abstract void sort(int[] numbers);

protected void swap(int[] numbers, int i, int j) {
int temp = numbers[i];
numbers[i] = numbers[j];
numbers[j] = temp;
}

protected void validateInput(int[] numbers) {
if (numbers == null) {
throw new IllegalArgumentException("You can't pass a null instance as parameter.");
}
}
}

0 comments on commit b5291a0

Please sign in to comment.