Download the the BlueJ project (NameLookup.zip) for this assignment and open it in BlueJ. You will see that it is composed of three classes, of which two are missing some code. You will complete that code and then extend the code in all three classes in various ways.
The program is designed to allow users to see the popularity rank of surnames (i.e., last names). It reads in a file that contains, in alphabetical order, a list of names and their popularity rank. Here is what the first few lines of the file look like:
The first line contains the number of name/rank pairs in the file, which is followed by that many name/rank pairs.
The main class is called NameLookup, and it handles all the interaction with the user. You don't have to modify anything in this file to begin, and will only make minor modifications in it later. It asks the user for the name of the data file and then creates a Surnames object, passing it that filename. It then repeatedly asks the user for a name and displays that name's rank. If the name is not found it prints out a message to that effect. You can see this in action in the screenshot attachednameLookup.gif
(the indented lines are not generated yet).
The name/rank pairs are stored as SurnameInfo objects. This is a simple object that just stores that info and has getters and setters for name and rank.
The middle class is called Surnames and it stores all of the SurnameInfo objects in an array. It also has a method that returns the rank of a name if it exists and -1 otherwise. It also has a method that returns the number of SurnameInfo objects stored.
Your goal is to complete the project so users can look up the rank of various surnames. This is done by using the search algorithms discussed in class. The linear search algorithm is already present in the Surnames class - you will need to add the other two search methods. When completed the interaction with the user should look like the following.