CS Logo

Project 3 - Due Thursday, July 25th before midnight.

 

In this project you will write a contact list program. Many of you will find this assignment challenging so start early and ask lots of questions.

 

Your program will store entries consisting of:

Person's Name

Telephone Number

Home Address

Email Address

 

Your address book program will allow the user to do four things with the entries:

 

1) Add an entry to the contact list.

 

2) Retrieve an entry from the contact list by name.

 

3) Print all entries in the contact list.

 

4) Erase an entry in the contact list by name.

 

Your address book should not place a fixed limit on the number of entries it can hold. You will have to use dynamic arrays to accomplish this. Whenever the array you are using runs out of space allocate a new one that is twice as large. Then copy the data from the old array into the new one and delete the old array.

 

Use pointers to keep track of the entries, which will themselves be arrays of pointers to character arrays.

 

You may handle deletion of an entry in the contact list by replacing the name of the contact with _deleted_.

 

You will need to write a function that can search your entries by name for the display by name and delete by name functions. This search function should return a pointer to the arrays containing the information to be deleted or displayed and ignore "deleted" entries.

 

The maximum length of the Person's Name, telephone number, and address may be fixed.

 

Example Run:

 

Welcome to the CS151 Contact List

 

Available actions:

 

1. Enter a new contact 

2. Delete a contact

3. Display a contact

4. Print all contacts

5. Quit program

 

Press 1, 2, 3, 4 or 5 to perform an action. 1

 

Enter the contacts name: George Bush

Enter the address: 1600 Pennsylvania Avenue NW, Washington, DC 20500

Enter the telephone number: 202-456-1414

Enter the email address: president@whitehouse.gov

 

Available actions:

 

1. Enter a new contact 

2. Delete a contact

3. Display a contact

4. Print all contacts

5. Quit program

 

Press 1, 2, 3, 4 or 5 to perform an action. 1

 

Enter the contacts name: Dick Cheney

Enter the address: S-212, Capitol Building, Washington, DC 20510

Enter the telephone number: 202-456-7549

Enter the email address: vice.president@whitehouse.gov

 

Available actions:

 

1. Enter a new contact 

2. Delete a contact

3. Display a contact

4. Display all contacts

5. Quit program

 

Press 1, 2, 3, 4 or 5 to perform an action. 3

 

Enter the name of the contact you would like to display: George Bush

 

Name: George Bush

Address: 1600 Pennsylvania Avenue NW, Washington, DC 20500

Telephone Number: 202-456-1414

Email: president@whitehouse.gov

 

Available actions:

 

1. Enter a new contact 

2. Delete a contact

3. Display a contact

4. Print all contacts

5. Quit program

 

Press 1, 2, 3, 4 or 5 to perform an action. 2

 

Enter the name of the contact you would like to delete: Dick Cheney

Entry for Dick Cheney deleted.

 

Available actions:

 

1. Enter a new contact 

2. Delete a contact

3. Display a contact

4. Print all contacts

5. Quit program

 

Press 1, 2, 3, 4 or 5 to perform an action. 2

 

Enter the name of the contact you would like to display: Diane Feinstein

Entry for Diane Feinstein not found.

 

Available actions:

 

1. Enter a new contact 

2. Delete a contact

3. Display a contact

4. Print all contacts

5. Quit program

 

Press 1, 2, 3, 4 or 5 to perform an action. 3

 

Enter the name of the contact you would like to delete: Dick Cheney

Entry for Dick Cheney not found.

 

Available actions:

 

1. Enter a new contact 

2. Delete a contact

3. Display a contact

4. Print all contacts

5. Quit program

 

Press 1, 2, 3, 4 or 5 to perform an action. 5

 

Grading:

 

Each action (add, delete, display, and display all) will be graded out of 20 points.

Up to 20 points more will be awarded for style.

 

If your program only allows a fixed number of entries 10 points will be deducted.

 

Programs that do not compile will receive zero points.