-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatm.cpp
More file actions
68 lines (59 loc) · 2.13 KB
/
atm.cpp
File metadata and controls
68 lines (59 loc) · 2.13 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
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include "Bank.h"
#include <memory>
using namespace std;
const std::string username = "Admin";
const std::string password = "123456";
std::unordered_map<std::string, std::unique_ptr<Account>> initializeStudents();
int main() {
std::unordered_map<std::string, std::unique_ptr<Account>> students = initializeStudents();
std::string loggedInUsername;
Account* loggedInUser = nullptr;
while (true) {
std::cout << "\n----- STC Student Banking Management System -----\n";
std::cout << "1. Log in\n";
std::cout << "2. View Account Data\n";
std::cout << "3. Add money\n";
std::cout << "4. Withdraw\n";
std::cout << "5. Log out\n";
std::cout << "6. Exit\n";
int choice;
std::cout << "Enter your choice (1-6): ";
std::cin >> choice;
if (choice == 1) {
if (loggedInUser == nullptr) {
loggedInUser = login(students, loggedInUsername, username, password);
} else {
std::cout << "You are already logged in.\n";
}
} else if (choice == 2) {
if (loggedInUser != nullptr) {
viewAccount(loggedInUser);
} else {
std::cout << "You need to log in first.\n";
}
} else if (choice == 3) {
if (loggedInUser != nullptr) {
addMoney(loggedInUser);
} else {
std::cout << "You need to log in first.\n";
}
} else if (choice == 4) {
if (loggedInUser != nullptr) {
withdrawMoney(loggedInUser);
} else {
std::cout << "You need to log in first.\n";
}
} else if (choice == 5) {
loggedInUser = nullptr;
loggedInUsername = "";
std::cout << "Logged out successfully!\n";
} else if (choice == 6) {
break;
} else {
std::cout << "Invalid choice. Please try again.\n";
}
}
std::cout << "Thank you for using the STC Student Banking Management System!\n";
return 0;
}