I need help with this program,actually i want to do Telephone directory,that will search an existing user by either name,surname ,tel.number so on so forth .I have already started it and have some skeletons of intended methods that i'd like to include in it .problem being how to write their implementations
Code:#include <iostream> #include <fstream> #include <string> using namespace std; struct Personal_info { string name; string Last_name; int Mobil_Num; string email; }; struct Address { string city; string street; }; class Telephone_Dir { // I have used arrays of the structs Personal_info and Address to hold the information in the directory // We want on directory to hold a large number of entries, so each Telephone_Dir class has a large array of // Personal_info and Address structs. public: Telephone_Dir(); Telephone_Dir(int); void AddEntry(Personal_info,Address); void AddEntry(); void Display(); void SearchForEntry(); void ShowHelp(); private: int size_of_directory; int num_of_entries; Personal_info *pers; Address *addr; }; Telephone_Dir::Telephone_Dir() // Constructor for Telephone class // Initialize all private values. { size_of_directory = 400; num_of_entries = 0; pers = new Personal_info[size_of_directory]; addr = new Address[size_of_directory]; } // Constructor that takes in specified size of directory Telephone_Dir::Telephone_Dir(int size) { size_of_directory = size; num_of_entries = 0; pers = new Personal_info[size_of_directory]; addr = new Address[size_of_directory]; } void Telephone_Dir::AddEntry(Personal_info P_info,Address Addr_orig) { pers[num_of_entries] = P_info; addr[num_of_entries] = Addr_orig; num_of_entries++; } void Telephone_Dir::AddEntry() { string surname = ""; cout << "User entry module" << endl; char quit_char = 'Y'; while(quit_char == 'Y' || quit_char == 'y') { cout << endl << "Add Entry #" << num_of_entries << endl; cout << "\n*************\n" << endl; cout << "Name: "; cin >> pers[num_of_entries].name; cout << "Surname: "; cin >> pers[num_of_entries].Last_name; cout << "Email: "; cin >> pers[num_of_entries].email; cout << "Mobile: "; cin >> pers[num_of_entries].Mobil_Num; cout << "City: "; cin >> addr[num_of_entries].city; cout << "Street: "; cin >> addr[num_of_entries].street; // Add in rest of input cout << "Successfully added Entry #" << num_of_entries << endl; cout << "Do you want to add another? [Y/N] "; cin >> quit_char; num_of_entries++; } } void Telephone_Dir::Display() { // Display entire Directory? for (int i=0; i<num_of_entries; i++) { cout << "Entry #" << i << endl; cout << "---------" << endl; cout << "Name: " << pers[i].name << endl; cout << "Surname: " << pers[i].Last_name << endl; cout << "Email: " << pers[i].email << endl; cout << "Mobile: " << pers[i].Mobil_Num << endl; //Add in prints for rest of fields cout << "City: " << addr[i].city << endl; cout << "Street: " << addr[i].street << endl << endl; } } void Telephone_Dir::SearchForEntry() { char option; cout<<"\nAre u searching according to Personal information or Address ?\n "; cout<<"\nThen type in either keyword (P) for the first choice or (A) for the latter\n "; cin>>option; if (option='P'||'p') { char str; cout<<"\nEnter an entry u r looking for\n"; cin>>str; }