// PhoneBook.cpp #include "PhoneBook.h" #include using std::ifstream; #include using std::cin; using std::cout; using std::endl; #include using std::map; using std::pair; #include using std::string; void PhoneBook::run() { entry_list.read_file(kcsFileName); bool done = false; do { display_entry_and_menu(); cout << "choice: "; char command; cin >> command; cin.get(); // new line char execute(command, done); cout << endl; } while (!done); } void PhoneBook::execute(char command, bool & done) { switch (command) { case 'n': { entry_list.move_to_next(); break; } case 'p': { cout << "Not yet implemented\n"; break; } case 'e': { if (entry_list.empty()) return; cout << "new number: "; string new_number; getline(cin, new_number); entry_list.edit_current(new_number); break; } case 's': { cout << "name: "; string name; getline(cin, name); entry_list.find(name); break; } case 'a': { cout << "new name: "; string new_name; getline(cin, new_name); cout << "phone number: "; string new_number; getline(cin, new_number); entry_list.add(new_name, new_number); break; } case 'd': { cout << "Not yet implemented\n"; break; } case 'q': { entry_list.write_file(kcsFileName); done = true; break; } }; }