I am given the code below and need to add a few things to it: after developing the code i have these are still the things I really am not sure how to finish. Any help would be greatly appreciated. Thank you
- Add a command ‘d’ for delete to delete an entry corresponding to a name typed by the user.
- Add an edit command to allow a user to edit one or more of the fields in the phonebook
- Allow a partial match to find or delete an entry. For example, “F mi” would match any entry with “mi” in the name, for example “Smith” or “Hermit” or Mitchell. You may use the function “find” in C++ for this feature.
- Make the program object-oriented. This means having a separate class for the internal representation of a phonebook, with methods like sort, list, or delete.
- The phonebook class must be defined with a separate header file (.h) and a separate implementation file (.cpp). The header file will include public and private variables and function prototypes.
- The implementation (.cpp) file for the phonebook class will include the implementation of all functions in the class. The definition of these functions must use the scope resolution operator to define methods (i.e. no inline functions within a class).
for(int j=0; j < num_entries; j++) {
for(i = j+1; i < num_entries; i++) {
if(contactList[j].name.compare(contactList[i].name) > 0) {
//Swap the entries if their names are not in ascending order
temp = contactList[j];
contactList[j] = contactList[i];
contactList[i] = temp;
}
}
}
cout << "Sorted the list. Press l to list all the contacts";
}
void listAllContacts() {
int i = 0;
while (i < num_entries) {
cout << "-- " << contactList[i].name << " "
<< contactList[i].number << endl
<< "-- " << contactList[i].notes << endl << endl;
i++;
}
}
int main(){
string name, number, notes;
string FileName;
char command;
FileName = "PhoneData.txt";
ReadFile ();
cout << "Use \"e\" for enter, \"f\" for find, \"q\" to quit."
<< endl << "Command: ";
cin >> command;
while (command != 'q'){
switch (command){
case 'e': cin >> name; cout << "Enter Number: ";
cin >> number; cout << "Enter Notes: ";
cin.ignore(); getline(cin, notes);
add_name(name, number, notes); break;
case 'f': cin >> name; retrieve_name(name); break;
case 's': sortList(); break;
case 'l': listAllContacts(); break;
}
cout << "\nCommand: "; cin >> command;
}
StoreFile();
cout << "All set !";
return 0;
}