Question: An input file is used as data source for a telephone directory program, the first line contains the full name of the phonebook owner, second
An input file is used as data source for a telephone directory program, the first line contains the full name of the phonebook owner, second line contains the number of contacts, each of the following line represent one contact and consists of the first name, followed by the last name and finally the phone number. Create a class called Person with the following data and functions members: ownerName ( private data member) fName of type vector (private data member). lName of type vector (private data member). phone of type vector (private data member). getOwnerName() public function to return the phonebook owner name. setOwnerName(string own) public function to set the phonebook owner name. getFirstName(int index) public member function to return the firstName located at index. getLastName(int index) public member function to return the lastName located at inde. getPhone(int index) public member function to return the phone located at index. addContact(string first_name, string last_name,int ph) public member function add the contact info to their corresponding vectors. deleteContact(int index) public member function to delete the contact located at index. Default constructor, will load the contacts information in the file input.txt to the vectors. Save, will save the contacts informations found in vectors to the input.txt file. Int searchByfirstName(string target), will return the index at which the contact last name target is found ( for simplicity search for the whole text == not find). Int searchBylastName(string target), same as above but will search in lName. Int searchByPhone(int phone), same as above but will search in phone. printAt(int index), will print the contact at index. Your main() should create an object of the Person class and continuously ask the user for the required action from the following actions list: 1. Search by First Name. 2. Search by Last Name. 3. Delete by phone number. 4. Exit. For the first 2 actions, your program should ask the user for the target and print the first name, last name and phone for the found contact, error message otherwise. In Action 3, you should ask the user for a phone number and delete the contact who has it. The last action is to save contact back into the file and exit the whole program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
