/* Java application for the purpose of testing the TimeOfDaySorter and ** CalendarDateSorter classes, both of which are (concrete) child classes ** of Sorter. ** ** Author: R. McCloskey ** Date: Feb. 2026 */ public class SorterApp { public static void main(String[] args) { sortTimesOfDay(); System.out.println(); sortCalendarDates(); } /* Creates a hard-coded array of TimeOfDay objects, prints them, ** sorts them, and prints them again. */ public static void sortTimesOfDay() { TimeOfDay[] times = new TimeOfDay[] { new TimeOfDay(3, 45, false), new TimeOfDay(9, 1, true), new TimeOfDay(12, 54, true), new TimeOfDay(5, 14, false), new TimeOfDay(5, 45, true), new TimeOfDay(10, 0, true), }; System.out.println("About to sort an array of TimeOfDay objects..."); System.out.println("Array before sorting:"); printArray(times); TimeOfDaySorter sorter = new TimeOfDaySorter(); sorter.sort(times); System.out.println("\nArray after sorting:"); printArray(times); } /* Creates a hard-coded array of CalendarDate objects, prints them, ** sorts them, and prints them again. */ public static void sortCalendarDates() { CalendarDate[] dates = new CalendarDate[] { new CalendarDate(3, 14, 2010), new CalendarDate(12, 1, 1978), new CalendarDate(4, 17, 2023), new CalendarDate(8, 24, 1856), new CalendarDate(3, 30, 1999), new CalendarDate(5, 16, 1975), new CalendarDate(6, 14, 1999), new CalendarDate(6, 5, 1999) }; System.out.println("About to sort an array of CalendarDate objects..."); System.out.println("Array before sorting:"); printArray(dates); CalendarDateSorter sorter = new CalendarDateSorter(); sorter.sort(dates); System.out.println("\nArray after sorting:"); printArray(dates); } /* Prints the elements of the given array, one per line. */ private static void printArray(Object[] ary) { for (int i=0; i != ary.length; i++) { System.out.println(" " + ary[i]); } System.out.println(); } }