CMPS 144L
Lab Activity: String Sorting Class Hierarchy

You should download the following Java classes, two of which it is your job to complete.

Here are two sample data files whose contents are suitable for use as input by the StringSortApp application. The expected format for input is a positive integer N, followed by at least N strings, one per line.

As presented in lecture, instances of child classes of StringSorter have a sort() method —inherited from StringSorter— that rearranges the elements of a given String[] array into ascending order consistent with the ordering relation "decided by" the isLessThan() method (which is what the sort() method uses to compare array elements against each other). Literally, isLessThan(), given strings s1 and s2, decides whether or not s1 < s2.

But isLessThan() is purposely defined to be abstract in StringSorter, which is to say that no method body is found there. The intent is that each of StringSorter's child classes will provide a concrete version of isLessThan() (i.e., one having a body), thereby implementing its own ordering relation (i.e., its own criteria for deciding whether or not s1 < s2).

The two child classes of StringSorter that are given to you in full have isLessThan() methods that, respectively, decide whether s1 < s2 with respect to lexicographic order and, respectively, length-lexicographic order (both of which were discussed in lecture).

You are to complete two additional child classes. One's isLessThan() method is intended to decide "reverse lexicographic order". Which means that it should judge s1 < s2 to be true iff, according to lexicographic order, s1 > s2 is true. (Or, if you prefer, you can replace s1 > s2 by ¬(s1 < s2).)

The other one's isLessThan() method should judge s1 < s2 to be true iff, according to lexicographic order, s1' < s2', where s1' and s2' are copies of s1 and s2 in which all letters have been converted to lower case (or upper case, if you prefer). Thus, for example, in lexicographic order, we have "Zebra" < "ant" because 'Z' < 'a', but in the ordering that we are describing ("lexicographic case insensitive") we would have "ant" < "Zebra" (because 'a' < 'z').
Note: The toLowerCase() (or toUpperCase()) method in the String class would come in handy here.

Upon completion, submit StringSorterLexicoReverse.java and StringSorterLexicoCaseInsenstive.java to the appropriate folder.