-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
43 lines (37 loc) · 1.09 KB
/
Copy pathmain.cpp
File metadata and controls
43 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "dictionary.h"
#include <iostream>
int main() {
Dictionary dict;
dict.loadFromFile("dictionary.txt");
std::string word, definition;
int choice;
do {
std::cout << "1. Add Word\n2. Remove Word\n3. Find Word\n4. List Words\n5. Exit\nEnter choice: ";
std::cin >> choice;
switch (choice) {
case 1:
std::cout << "Enter word: ";
std::cin >> word;
std::cout << "Enter definition: ";
std::cin.ignore();
std::getline(std::cin, definition);
dict.addWord(word, definition);
break;
case 2:
std::cout << "Enter word to remove: ";
std::cin >> word;
dict.removeWord(word);
break;
case 3:
std::cout << "Enter word to find: ";
std::cin >> word;
std::cout << "Definition: " << dict.findWord(word) << std::endl;
break;
case 4:
dict.listWords();
break;
}
} while (choice != 5);
dict.saveToFile("dictionary.txt");
return 0;
}