< previous page page_882 next page >

Page 882
date would be useful, we can implement, test, and add them to our set of date operations.
We have said that data abstraction is an important principle of software design. What we have done here is an example of data abstraction. From now on, when a problem needs a date, we can stop our decomposition at the logical level. We do not need to worry about implementing a date each time.
Problem-Solving Case Study Birthday Calls
0882-01.gif
Problem: In Chapter 10, we commented that everyone has at least one friend who never forgets important dates in the lives of his or her friends. Let's write a program to go through your address book and print the names and phone numbers of all the people who have birthdays within the next two weeks, so you can give them a call.
Input: Today's date (from the keyboard); and a list of names, phone numbers, and birth dates (file friendFile). The file friendFile is the address book created by running the Friends program in Chapter 14. Entries in this file are in the form
John Arbuthnot
(493) 384-2938
1/12/1970

Mary Smith
(123) 123-4567
10/12/1960
Output: The names, phone numbers, and birthdays of any friends whose birthdays are within the next two weeks. A sample of the output is
John Arbuthnot
(493) 384-2938
January 12, 1996
Note that the date printed is the friend's next birthday, not the friend's birth date.

 
< previous page page_882 next page >