|
|
|
|
|
|
|
PhoneType phone;
DateType birthDate;
};
void GetCurrentDate( DateType& );
void GetEntry( ifstream&, EntryType& );
void OpenForInput( ifstream& );
void PrintEntry( EntryType, DateType );
int main()
{
ifstream friendFile; // Input file of friends' records
EntryType entry; // Current record from friendFile
// being checked
DateType currentDate; // Month, day, and year of current day
DateType birthday; // Date of next birthday
DateType targetDate; // Two weeks from current date
int birthdayYear; // Year of next birthday
int count; // Loop counter
OpenForInput(friendFile);
if ( !friendFile )
return 1;
GetCurrentDate(currentDate);
targetDate = currentDate;
for (count = 1; count <= 14; count++)
targetDate.Increment();
GetEntry(friendFile, entry);
while (friendFile)
{
// Invariant (prior to test):
// All previous values of entry have been
// read from friendFile and processed
if (targetDate.Year() != currentDate.Year() &&
entry.birthDate.Month() == 1)
birthdayYear = targetDate.Year();
else
birthdayYear = currentDate.Year();
birthday.Set(entry.birthDate.Month(), entry.birthDate.Day(),
birthdayYear);
if (birthday.ComparedTo(currentDate) >= SAME &&
birthday.ComparedTo(targetDate) <= SAME)
PrintEntry(entry, birthday);
GetEntry(friendFile, entry);
}
|
|
|
|
|
|