-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
102 lines (78 loc) · 2.54 KB
/
main.cpp
File metadata and controls
102 lines (78 loc) · 2.54 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#include "utils.cpp"
#include "login.cpp"
#include "student.cpp"
#include "admin.cpp"
#include "teacher.cpp"
#include <iostream>
#include <chrono>
#include <thread>
#include <atomic>
#include <string>
using namespace std;
Utils* Utils::instance = nullptr;
std::atomic<bool> stop_loading(false);
void loading_screen(int dots) {
std::cout << "\e[?25l";
if (stop_loading) return;
std::string loading_text = "Loading";
for (int i = 0; i < dots; ++i) {
loading_text += ".";
}
std::cout << "\r" << loading_text << std::string(7 - dots, ' ') << std::flush;
std::this_thread::sleep_for(std::chrono::milliseconds(500));
loading_screen((dots % 3) + 1);
std::cout << "\e[?25h";
}
int main() {
Utils& utilsMain = Utils::getInstance();
std::thread loading_thread(loading_screen, 1);
std::cout << "\033[94mPress Enter to start\033[0m" << std::endl;
std::cin.get();
utilsMain.delayAnimation(10);
stop_loading = true;
if (loading_thread.joinable()) {
loading_thread.join();
}
Login user;
string username, password;
bool checkCredentials = true;
while (checkCredentials) {
if (user.startMenu() == 1)
return(0);
utilsMain.delayAnimation(10);
cout << "\033[94m" << R"( _ _
| | ___ __ _(_)_ __
| | / _ \ / _` | | '_ \
| |__| (_) | (_| | | | | |
|_____\___/ \__, |_|_| |_|
|___/
)" << "\033[0m" << std::endl;
cout << "Username: \033[32m";
cin >> username;
cout << "\033[0mPassword: \033[32m";
cin >> password;
cout << "\033[0m";
string check = user.checkCredentials(username, password);
cout << check << endl;
if (check == "\033[32m\n[Login successful!]\033[0m")
checkCredentials = false;
else
checkCredentials = true;
utilsMain.delayAnimation(400);
string accountType = user.getAccountType();
string name = user.getName();
if (!checkCredentials){
if (accountType == "0"){
Admin adminUser;
checkCredentials = adminUser.adminMenu(name);
} else if (accountType == "1"){
Student studentUser;
checkCredentials = studentUser.studentMenu(name);
} else if (accountType == "2") {
Teacher teacherUser;
checkCredentials = teacherUser.teacherMenu(name);
}
}
}
return 0;
}