I am having trouble with several parts of this program. The gist is that I need to create an address book using a record structure and a sorted linked list. The problem is that I am struggling to understand how to execute the following:
- In the main function, how to locate a specific record to delete/change data elements.
- In the member functions, how to code the enum RelationType ComparedTo() function, so that it compares the parameter to the nodes in the linked list.
#include "stdafx.h"
#include "SortedType.h"
#include "AddressBook.h"
#include <string>
#include <iostream>
usingnamespace std;
int main()
{
cout << "Welcome to the Message Greeting program!" << endl;
cout << "This program creates auto-generated birthday and anniversary greetings, based upon information in an address book of your creation." << endl;
cout << "Please select one of the following menu options to proceed:" << endl;
cout << endl;
menuOptions();
}
void menuOptions()
{
SortedType list;
int input;
int change;
string nameChange;
int dateUpdate;
bool finished = false;
bool moreToDo = false;
do
{
cout << "What would you like to do?" << endl;
cout << endl;
cout << "Enter 1 to add a new entry to the Address Book." << endl;
cout << "Enter 2 to delete an entry from the Address Book." << endl;
cout << "Enter 3 to change a name OR date in the Address Book." << endl;
cout << "Enter 4 to generate a birthday greeting." << endl;
cout << "Enter 5 to generate an anniversary greeting." << endl;
cout << "Enter 6 to exit the program." << endl;
cin >> input;
switch (input)
{
case 1: cout << "Please enter the first and last name of the new contact: " << endl;
getline(cin, record->name);
cout << "Please enter the person's street address now: " << endl;
getline(cin, record->address);
cout << "Please enter the person's date of birth in the following format: mm/dd/yyyy" << endl;
cin >> record->dateOfBirth;
cout << "Please enter the person's anniversary date in the following format: mm/dd/yyyy" << endl;
cin >> record->anniversaryDate;
list.PutItem(record);
break;
case 2: cout << "Which entry are you looking to delete?" << endl;
//cin >> list.DeleteItem(record); I don't know h
list.DeleteItem(record);
break;
case 3:
do
{
cout << "What portion of the address record are you looking to change?" << endl;
cout << "Enter 1 for name." << endl;
cout << "Enter 2 for address." << endl;
cout << "Enter 3 for date." << endl;
cin >> change;
if (change == 1)
{
cout << "Which record would you like to change the name for?" << endl;;
}
elseif (change == 2)
{
cout << "Which record would you like to change the address for?" << endl;
}
elseif (change == 3)
{
do
{
cout << "Which date field would you like to change: DOB or Anniversary?" << endl;
cout << "Enter 4 for DOB." << endl;
cout << "Enter 5 for anniversary." << endl;
cin >> dateUpdate;
if (dateUpdate == 4)
{
cout << "Which record would you like to change the DOB?" << endl;
}
elseif (dateUpdate == 5)
{
cout << "Which record would you like to change the anniversary date?" << endl;
}
else
{
cout << "Sorry. That isn't a valid option. Please try again." << endl;
}
} while (moreToDo = false);
}
else
{
cout << "Sorry. That isn't a valid option. Please try again." << endl;
}
} while (finished = false);
break;
case 4: list.displayBirthday();
break;
case 5: list.displayAnniversary();
break;
default: exitProgram();
}
} while (input != 6);
}
void exitProgram()
{
cout << "Thank you very much for using the Message Greeting program!" << endl;
cout << "We hope to see you again soon! Goodbye!" << endl;
system("pause");
EXIT_SUCCESS;
}