CSC 241- Assignment#4--Extra Credit (Due December 19, 2003) [20 Points]


A Rolodex Application

Develop a rolodex application program that provides users with the following options:

  1. Find someone's phone number.
  2. Add a name/phone number.
  3. Remove a name and its phone number from the rolodex.
  4. Change someone's phone number.
  5. Display partial/full list of name/phone numbers.

rolodexEntry

in order to develop the application program, you will need to first develop a rolodexEntry class that implements Comparable. This class must have two fields: name and phone number. It needs a compareTo method, and a toString method. This class is similar to elementForTest class used in test2 from lab#5. The compareTo method must return the result of comparing the name field of its parameter against the object's own name field. The toString method must concatenate name and phone number of the object as a String and return that.

rolodexApp

Rolodex application keeps name/phone numbers in a Tree. Use test2 used in lab5 as a template and follow the algorithm given below:

  1. construct a set as either a tree or hashTable.
  2. loop forever
    1. Using, simple a series of System.out.printlns, provide a menu:
                 1. Find an Entry
                 2. Add an Entry 
                 3. Delete an Entry 
                 4. Update Phone Number 
                 5. Display partial/full list of name/phone numbers
                 6. Quit
                  
    2. Get user's choice. testSamePercentage.java should be looked at here to see how one reads from standard input and convert a string to a number.
    3. switch choice
      • case 1: prompt for and read a name;
        create a rolodexEntry object with just the name, find it in the set;
        output phone number in the object returned or a NOT FOUND message when null is returned. break
      • case 2: prompt for and read a name and phone number;
        create a rolodexEntry; use the find method to see if it is already in the set; if not, add the entry.
        output success or failure. break.
      • case 3: prompt for and read a name to delete.
        create a rolodexEntry using just the name; use the find method to see if it is in the set; if it is, remove the entry.
        output success or failure. break.
      • case 4: prompt for and read a name and a new phone number.
        create a rolodexEntry object with the name only, find it in the set;
        If in the set, change phone number field of the entry returned to the phone number read.
        output success or failure. break.
      • case 5: Display partial/full list of name/phone numbers
        This option enables the user to either see all names/phone numbers or a partial set of them.
        prompt for a partial name/*. Lets assume the user response is stored in w. If w is a "*", all name/phone numbers are displayed, otherwise, the subset of the elements whose name start with the content of w are displayed. For example, if w is "la", all names in the rolodex that start with the substring la are displayed. Keep in mind that the toArray returns all elements from the set in an array, so you can use it to return all name/phone numbers and selectively display what you need.
      • case 6: return.
    4. End Switch
  3. End Loop

What to Turn In

rolodexApp.java and rolodexEntry.java files.