New Concepts Tested by This Program

New Concepts Tested by This Program

Assignment 4

CMSC 204

New concepts tested by this program

Hash Tables

You will be creating a program that holds a simple Address Book and then lets you do a reverse phone number look up. You will be storing the address book ina hash table implemented with buckets/chaining.

Data Element - Person

Create a class Person which implements PersonInterface. The hashCode method should return an integer based on the following hash function:

hashcode = (p1 * (areaCode + p2 * exchangeCode) + extensionCode)

the key is the phone number as a string in the form: (XXX)XXX-XXXX

p1 is the prime 23 and p2 is the prime 31

In the phone number (555)123-4567

areaCode = 555

exchangeCode = 123

extensionCode = 4567

if the hashcode is negative – use the absolute value

Data Structure - HashTable

Create a class HashTable which implements HashTableInterface with buckets. You can use an array of linked lists(of Person objects). You may add any other methods you think are necessary.

Data Managers – AddressBookUtility

Createa class AddressBookUtility that implements the AddressBookUtilityInterface. This class will use an object of yourHashTableclass to hold the Person objects for the address book. The format of the file to be read from or written to is as follows:

Firstname<space>Lastname<space>PhoneNum<space>address<newline>

Example:

John Smith (222)555-2345 2310 Oak St., Willmington, VA 24488

You can assume all first names and last names will only be one word (no spaces)

Exception Classes – KeyInUseException, InvalidKeyException

The phone numbers in this address book must be unique because we are using them as the key to place them in the hash table (I know it’s not ideal, but it simplifies the program). If a Person object being added to the hash table has the same phone number as an object in the hash table, the KeyInUseException will be raised.

If the key is not in the format (XXX)XXX-XXXX where the X is a digit, the InvalidKeyException will be raised.

GUI Driver

If the user selects the Read Text File button, use the FileChooser to ask the user for the location of the text file to be read. If the user selects Add, retrieve the information from the textbox fields and add to the address book. When the user selects Reverse Look Up, retrieve all the phone numbers in the left text area and print the corresponding lastname and firstname for that phone number. When the user selects Write Text File, use the FileChooser to ask the user for the location of the text file to be written to. When the user selects Exit, the program terminates.

Type in phones numbers for reverse look up

Error message if phone number is not in correct format

Adding a person with a phone number already in the address book

Program Grade Sheet

Assignment #4

CMSC 204

Name ______Date/Time ______

DOCUMENTATION (20 pts)

Javadoc foruser created classes:8pts _____

Test Cases8pts _____

JUnit Test Class

Create a test class for your HashTable class

Implement the student tests in AddressBookUtilityTest

UML Diagram4pts _____

PROGRAMMING(80 pts)

Programming Style

Internal class documentation (within source code)6pts _____

Class description using Javadoc

Author’s Name, Class, Class Time

Methods commented using Javadoc

Accuracy

Public Tests and the test you created 10pts _____

Private Tests10pts _____

Program Details

  1. Person class4pts _____
  2. Uses PersonInterface
  3. Implements all methods of PersonInterface
  4. Implement static methods hashKey and isValidKey
  5. HashTable class16pts _____
  6. Uses HashTableInterface
  7. implementedwith buckets and linkedList
  8. implements all methods of HashTableInterface
  9. AddressBookUtility class 14pts _____
  10. Uses AddressBookUtilityInterface
  11. Uses an object of yourHashTable data structure
  12. Implements all methods of AddressBookUtilityInterface
  13. Exception classes10pts _____
  14. InvalidKeyException
  15. KeyInUseException
  16. Creates and uses both exceptions correctly
  17. GUI driver10pts _____
  18. Uses FileChooser to select files
  19. All user to entermultiple phone numbers and then shows

corresponding first and last name

  1. Allows user to add to the Address Book
  2. Alerts user when the phone number is invalid or already in use.
  3. Program user interface

Clear to user how data is to be entered

Output is easy to understand

Total100 pts _____