Sorting methods in the manager class can now be added. Only part of the manager class is now shown. /* * Super class: Dogs. Subclass: Working dogs * Read in from a text file */ package inheritance; public class DogsUI { public static void main(String[] args) { DogManager dm = new DogManager(); String text = dm.displayAll(); System.out.println(text); dm.bubbleSortName(); text = dm.displayAll(); System.out.println(text); dm.bubbleSortAge(); text = dm.displayAll(); System.out.println(text); } } ==================================================================== // Sorts alphabetically by the dog's name public void bubbleSortName (){ Dogs temp; for(int i = 0; i < size - 1; i++){ for (int j = 0; j < size -1 - i; j++) { String name1 = dogArray[j].getName(); String name2 = dogArray[j + 1].getName(); int value = name1.compareTo(name2); if(name1.compareTo(name2)> 0) { temp = dogArray[j]; dogArray[j] = dogArray[j + 1]; dogArray[j + 1] = temp; } // end if } // end inner loop } // end outer loop } // end method // ========================================================================== // Sorts numerically by the dog's age public void bubbleSortAge (){ Dogs temp; for(int i = 0; i < size - 1; i++){ for (int j = 0; j < size -1 - i; j++) { int age1 = dogArray[j].getAge(); int age2 = dogArray[j + 1].getAge(); if(age1 > age2) { temp = dogArray[j]; dogArray[j] = dogArray[j + 1]; dogArray[j + 1] = temp; } // end if } // end inner loop } // end outer loop } // end method // =========================================================================== OUTPUTS. First by text file. Second alphabetically. Third by age of the dog. run: Butch 2 false April 1 true Shaka 2 true Thabiso Morgan 4 false Ratty 9 false Ricky 1 false Khutso Tut 2 true Seal 1 false Marge April 1 true Butch 2 false Morgan 4 false Ratty 9 false Ricky 1 false Khutso Seal 1 false Marge Shaka 2 true Thabiso Tut 2 true April 1 true Ricky 1 false Khutso Seal 1 false Marge Butch 2 false Shaka 2 true Thabiso Tut 2 true Morgan 4 false Ratty 9 false BUILD SUCCESSFUL (total time: 0 seconds)