TreePhoneList, IHashedPhoneList, and JHashedPhoneList, as well as a Name class.
Each of the three phone list classes is to represent associations between names and telephone numbers. The first is to use a TreeMap, and the second and third are to use a HashMap. Each of these classes is to have a size() that returns the number of associations, and methods add, getNumber, and printSortedList, as described below. Telephone numbers are to be represented as strings.
The names in a phone list are to be instances of the Name class. Names consist of first names and last names, so this class is to have a constructor that takes two Strings as arguments. These Strings are to represent the first and last name (in that order). The class is also to implement the Comparable interface, with the compareTo method treating the last name as more significant than the first name. The class is to have a toString() method whose return value has the last name first.
The Name class is also to be responsible for keeping track of how many times its instances have been compared. In particular, it should have a static instance variable to keep track of the number of comparisons made, and methods resetCounter() and getCounter(). The first of these methods should reset the counter to have value 0, while the second should return the current value of the counter (as an int).
In each of the phone list classes, the add method is to take a name and a telephone number, and add the new assocation between these values to the phone list. It should return the telephone number previously associated with the name (and null if none exists). The getNumber method is to take strings representing the first and last names (in that order), and return the associated telephone number (or null if none exists). The printSortedList() method is to print a list of the associations, in sorted order by name. It has no return value.
The TreePhoneList class should implement printSortedList() simply by traversing the tree. The other classes should use a counting comparator (you may use the CountingComparator class given on the class web site if you want), and should have methods resetCounter() and getCounter() as in the Name class. The IHashedPhoneList class should pass the comparator to a version of insertion sort that takes a Comparator as a parameter. The JHashedPhoneList should pass the counting comparator to the Collections.sort method.
Test your classes with the class A7, which is available on the class web site. Don't forget to turn in a hard copy of the results of your testing. As always, you may define any additional classes or methods that you find useful. You will likely need equals() and hashCode() methods for the Name class. For the hashCode() method, you might consider using the hash code of the value of toString.