The purpose of this assignment is to build a phone book that will store contact information of people that you know. The contact information will be the address, phone number, and e-mail address. In this phone book you can add, delete, lookup, and update information about a person using their name as the key. The data structure that you will be using will be a dictionary.
All the names of the people and their contact information will be stored in a file called phone.txt. Each person will have the following pieces of information associated with him or her:
This program is menu driven. When the program is initiated, a function opens the file phone.txt reads the data from the file creates a ContactInfo object and stores that object as the value in a dictionary where the name of the person is the key. The menu choices are:
Phone Book
1. Add a Person
2. Delete a Person
3. Search for a Person
4. Update Information on a Person
5. Quit
Enter your selection:
The user will make a menu selection by typing a number between 1 and 5. If the user selects a number other than a number in that range then you will state that it is an invalid selection and ask the user to select again. You will keep prompting until the user either makes a valid selection or quits.
Each valid selection will be handled by a separate function. After your program has handled menu items 1 through 4, the same menu should reappear for additional requests by the user. The handling of each menu item is explained in detail below. When the user selects menu item 5, the appropriate function is called and then the program prints a message thanking the user.
Thank you for using the phone book.
1. Add a Person: This function will prompt the user to enter the following data:
Enter name:
Enter street:
Enter city:
Enter state:
Enter zip:
Enter country:
Enter phone number:
Enter e-mail address:
You will create a ContactInfo object and add that to the dictionary with
the name as key. Here are special cases that you need to consider:
2. Delete a Person: Prompt the user to enter the name.
Enter name:
If the name exists, delete the the person from the dictionary. Write a
message to that effect.
So-and-So was deleted from the phone book.
If the name does not exist write a message to that effect.
So-and-So does not exist in the phone book.
3. Search for a Person: Prompt the user to enter the name.
Enter name:
If the name exists, write the name and the contact information in a neat
format. If the name does not exist write a message to that effect.
So-and-So does not exist in the phone book.
4. Update Information on a Person: This function will prompt the user to enter the information below. The user should enter a valid name and any other piece or pieces of information that he wants to update. He may choose not to enter any data field that has not changed. For example, if only the e-mail address has changed for a person, then the user will enter only the name and the e-mail address and leave everything blank.
Enter name:
Enter street:
Enter city:
Enter state:
Enter zip:
Enter country:
Enter phone number:
Enter e-mail address:
If the name exists, retrieve the ContactInfo object from the dictionary
for that person. For those fields that are not blank change it in the
ContactInfo object and store it back in the dictionary.
So-and-So does not exist in the phone book.
5. Quit: In this function, you will open the file phone.txt for writing (not appending). You will write out all the key-value pairs in the file in exactly the same format that you read the data in. You will close the file after writing.
Before you turn your assignment in, you must thoroughly test each of the functionality. Here is a list of tests that you must perform and your program should pass each test.
For this assignment you may work with a partner. Both of you must read the paper on Pair Programming. .
The template of the code is given in a file called PhoneBook.py. We will be looking at documentation, descriptive variable and function names, clean logical structure, and adherence to the coding conventions discussed in class. The file will have a header of the following form:
# File: PhoneBook.py # Description: # Student Name: # Student UT EID: # Partner Name: # Partner UT EID: # Course Name: CS 313E # Unique Number: # Date Created: # Date Last Modified:
For grading purposes, all prompts should end in a colon character then a space character (': '). Do not place any colons in any other places in any prompt or printed output, including the returned results from the Search command (use dashes or some other punctuation). Matching the provided sample outputs/prompts will also expedite grading.
If you are working with a partner both of you will be submitting a single program (from either account) but make sure that you have your partner's name and eid in your program. If you are working alone, then remove the two lines that has the partner's name and eid in the header.
Use the Canvas system to to submit your PhoneBook.py file. We should receive your work by 11 PM on Friday, 21 September 2018. There will be substantial penalties if you do not adhere to the guidelines. Remember Python is case sensitive. The name of your file must match exactly what we have specified.