Program 5: Phone Directory

Purpose

The purpose of this assignment is to design and implement a complete program with no starter code. Additionally, it will give you experience using inheritance.

Problem Description

Write a program that allows a user to maintain an electronic copy of his or her PhoneBook. The user should repeatedly be given the following menu until he or she selects quit:

1. Add Entry
2. Delete Entry
3. Find Phone Number
4. Print Phone Book
5. Quit

Add Entry

The user is prompted for a Name, a note, and a PhoneNumber to store in his or her PhoneBook. If the note is empty, a Name should be created. If the note is not empty, a FriendName should be created.

If either of the following conditions arise, the information should not be added:

Delete Entry

The user is prompted for a Name. If the Name exists in the PhoneBook, the entry should be deleted.

Find Phone Number

The user is prompted for a Name. If the Name exists in the PhoneBook, the corresponding PhoneNumber should be displayed.

Print Phone Book

The entire contents of the PhoneBook is displayed in alphabetical order by last name. If two last names are the same, use the first name that comes alphabetically first to break the tie.

Quit

The program finishes.

Getting Started

Create a BlueJ project named Program5 with the following classes in it:

Name
Consists of a first name (e.g. "Mary") and a last name (e.g. "Smith").
FriendName
Inherits all information from Name and also contains a note field (e.g. "CS 160 classmate")
PhoneNumber
Consists of a 3 digit area code (e.g. 406), a 3 digit prefix (e.g. 994) and a 4 digit suffix (e.g. 4636).
PhoneEntry
Consists of a Name and a PhoneNumber.
PhoneBook
Consists of an arbitrary number of PhoneEntrys.
TestProgram
Should provide menu functionality similar to that of the Driver.java file of Program 4.

Grading (75 points possible)

Submission

E-mail the java files you wrote as an attachment to your lab TA no later than the start of your lab on Tuesday, December 9th. Late submissions receive no credit, but partial credit can be earned by making an ontime submission. The subject of the e-mail should be CS 160, Program 5, your name, your partner's name.

Valid XHTML 1.0!