// Massingill, Berna L. // 2000Apr19 // CS1321 // Program to Test Hash Table Class #include #include #include // has EXIT_SUCCESS #include #include "hashTable.h" int main(void) { hashTable h; string prompt = "Please enter an operation to perform:\n" " ?: this prompt again\n" " x: exit\n" " i: insert\n" " r: remove\n" " q: query\n" " p: print\n" " P: print with internal info\n"; string prompt2 = "Command?\n"; string reply; cout << prompt; cout << prompt2; while (getline(cin, reply)) { if (reply.size() > 0) { char c = reply[0]; if (c == '?') cout << prompt; else if (c == 'x') break; else if (c == 'i') { string key; cout << "Enter key to insert:\n"; getline(cin, key); h.insert(key); } else if (c == 'r') { string key; cout << "Enter key to remove:\n"; getline(cin, key); h.remove(key); } else if (c == 'q') { string key; cout << "Enter key to look up:\n"; getline(cin, key); if (h.query(key)) cout << "Matching key found\n"; else cout << "No matching key found\n"; } else if (c == 'p') { cout << "Contents of table:\n"; cout << h << endl; } else if (c == 'P') { h.printInfo(cout); } else cerr << "Invalid command\n"; } cout << prompt2; } cout << "That's all, folks!\n"; return EXIT_SUCCESS; }