-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
57 lines (50 loc) · 1.34 KB
/
main.cpp
File metadata and controls
57 lines (50 loc) · 1.34 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <map>
#include <string>
using namespace std;
class Database {
private:
map<string, string> data; // Key = Name, Value = Phone Number
void addData() {
string name, phone;
cout << "Enter name: ";
cin >> name;
cout << "Enter phone: ";
cin >> phone;
data[name] = phone;
cout << "✓ Saved: " << name << " → " << phone << "\n";
}
void findData() {
string name;
cout << "Enter name to find: ";
cin >> name;
if (data.count(name)) {
cout << "Found: " << name << " → " << data[name] << "\n";
} else {
cout << "✗ Not found.\n";
}
}
public:
void run() {
int choice;
do {
cout << "\n=== SimpleDB ===\n";
cout << "1. Add Data\n";
cout << "2. Find Data\n";
cout << "3. Exit\n";
cout << "Choice: ";
cin >> choice;
switch (choice) {
case 1: addData(); break;
case 2: findData(); break;
case 3: cout << "Goodbye!\n"; break;
default: cout << "Invalid choice.\n";
}
} while (choice != 3);
}
};
int main() {
Database db;
db.run();
return 0;
}