< previous page page_794 next page >

Page 794
Problem-Solving Case Study Automated Address Book
0794-01.gif
Problem: You have a pocket address book that you have used for years, and it is now falling apart. Instead of copying all the items into a new book, you decide to automate your address book, including the following information for each entry:
0794-02.gif
Input: A series of entries containing a first and a last name, a phone number, and a birth date. (We'll omit the address for this case study.) The exact form of an entry is to be determined.
Output: The entries in alphabetical order, written to a file friendFile.
Discussion: If we think of an address book as an abstract data type (Chapter 12), there are all kinds of interesting operations we might provide:
Enter a new person into the address book
Delete a person from the address book
Search for a name and print the person's phone number
Print all of the entries in the address book
Print a list of the people with birthdays each month
Print names and addresses in zip-code order to facilitate sending cards
.
.
.
Let's not be too ambitious. We should do the program in stages. In the first stage (this case study), we create the address book and save the information in a file. Because we want to enhance the program at a later time, we need to make the data structures as flexible as possible. As we do the top-down design, we pay particular attention to the development of the data structures. At first, we think of an address book as an abstraction and keep our algorithms general. As we refine our design, we make decisions about actual data structures to use and add more detail to the algorithms accordingly.
As we start our design phase for this problem, we call all the information about one person an entry. We want to keep our entries in order by last name so that we can use a binary search to locate specific people. We can either

 
< previous page page_794 next page >