Having done all this, the last thing we will need is to have QuickSort as a simple class (all the real work was already done in different classes):
public class QuickSort<E> extends AbstractSort<E> { public void sort(Sortable<E> sortable) { final var n = sortable.size(); final var qsort = new Qsort<E>(comparator,swapper); qsort.qsort(sortable, 0, n-1); } }
Do not forget that we also need a test! But, in this case, that is not much different than that of BubbleSort:
@Test public void canSortStrings() { final var actualNames = new String[]{ "Johnson", "Wilson", "Wilkinson", "Abraham", "Dagobert" }; final var expected = new String[]{"Abraham", "Dagobert", "Johnson", "Wilkinson", "Wilson"}; var sort = new QuickSort<String>(); ...