-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProject.cpp
More file actions
540 lines (453 loc) · 13.6 KB
/
Project.cpp
File metadata and controls
540 lines (453 loc) · 13.6 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
// Base class for both User and Admin
class Person {
protected:
string name;
public:
string getName() const
{
return name;
}
};
/// =============== USER ===================
class User : public Person {
// Private member variables
string name, dept, password;
char section;
int id, batch;
public:
// Constructor to initialize user details
User(string n, string d, string p, char s, int i, int b)
{
this->name = n;
this->dept = d;
this->password = p;
this->section = s;
this->id = i;
this->batch = b;
}
// Method to update user details
void updateUserDetails(string newDept, char newSection, string newPassword)
{
this->dept = newDept;
this->section = newSection;
this->password = newPassword;
}
// Getter methods to access user information
string getName()
{
return name;
}
string getDept()
{
return dept;
}
string getPass()
{
return password;
}
char getSection()
{
return section;
}
int getId()
{
return id;
}
int getBatch()
{
return batch;
}
};
/// =========== USER =============
/// ============= ADMIN ===============
class Admin : public Person {
public:
string name = "Shifa";
int code = 123456;
// Getter methods for admin information
string getName()
{
return name;
}
int getCode()
{
return code;
}
};
/// ============= ADMIN ===============
/// ================= ADMIN MANAGER ===================
class AdminManager {
private:
Admin admin;
public:
int loggedIndex;
AdminManager() : loggedIndex(-1) {} // loggedIndex = - 1
// Method for admin login
bool adminLogin(string n, int key)
{
if (admin.getName() == n && admin.getCode() == key)
{
if (loggedIndex != -1)
{
cout << "\t\t\tAnother Admin is already logged in. Please log out first" << endl;
return false;
}
loggedIndex = 1;
cout << "\t\tAdmin Login Successful" << endl;
return true;
}
cout << "\t\t invalid name/code" << endl;
return false;
}
// Method for admin logout
void logoutAdmin()
{
if (loggedIndex != -1)
{
cout << "\t\t\t Logout Successful" << endl;
loggedIndex = -1;
}
else
{
cout << "Please log in as admin" << endl;
}
}
};
/// =================== ADMIN MANAGER ===================
/// ============ USER MANAGER ==================
class UserManager {
public:
vector<User> users;
int loggedIndex; // index of the currently logged in user
UserManager() : loggedIndex(-1) {} // loggedIndex = - 1 // loggedIndex = false;
// Method for user registration
void RegisterUser()
{
string name, dept, password;
char section;
int id, batch;
cout << "\t\t\t Registration // Login Requirements" << endl;
cout << "1. Name: ";
cin.ignore();
getline(cin, name);
cout << "2. ID: ";
cin >> id;
cout << "3. Dept: ";
cin.ignore();
getline(cin, dept);
cout << "4. Section: ";
cin >> section;
cout << "5. Batch: ";
cin >> batch;
cin.ignore();
cout << "6. Create password: ";
getline(cin, password);
// Creating a new user object and adding it to the vector
User newUser(name, dept, password, section, id, batch);
users.push_back(newUser);
cout << "\t\tUser registered" << endl;
system("pause");
system("cls");
}
// Method for user login
bool loginUser(string name, int id, string pass)
{
for (int i = 0; i < users.size(); i++)
{
if (users[i].getName() == name && users[i].getId() == id && users[i].getPass() == pass)
{
if (loggedIndex != -1)
{
cout << "\t\t\tAnother user logged in. Please logout first" << endl;
return false;
}
loggedIndex = 1;
cout << "\t\t\t Login Successful" << endl;
return true;
}
}
cout << "\t\t\t Invalid Username/Password/ID" << endl;
return false;
}
// Method for user logout
void LogoutUser()
{
if (loggedIndex != -1)
{
cout << "\t\t\t Logout Successful" << endl;
loggedIndex = -1;
}
else
{
cout << "\t\t\tNo user is currently logged in. Please login" << endl;
}
}
// Method to display user profile
void displayProfile(string name)
{
for (int i = 0; i < users.size(); i++)
{
if (users[i].getName() == name)
{
cout << "\t\t\t =-=-=-=-= Profile =-=-=-=-=\n" << endl;
cout << "\t\tName: " << users[i].getName() << endl;
cout << "\t\tID: " << users[i].getId() << endl;
cout << "\t\tDept: " << users[i].getDept() << endl;
cout << "\t\tSection: " << users[i].getSection() << endl;
cout << "\t\tBatch: " << users[i].getBatch() << endl;
return;
}
}
cout << "\t\tUser not found" << endl;
}
// Method to edit user profile
void EditProfile(string name)
{
bool found = false;
for (int i = 0; i < users.size(); i++)
{
if (users[i].getName() == name)
{
found = true;
string dept, pass;
char section;
cout << "\t\t\t Editing Profile" << endl;
cout << "New Department: ";
cin.ignore();
getline(cin, dept);
cout << "New Section: ";
cin >> section;
cin.ignore();
cout << "New Password: ";
getline(cin, pass);
users[i].updateUserDetails(dept, section, pass);
cout << "\t\t\t Profile updated successfully" << endl;
}
}
if (!found)
{
cout << "\t\t\t User not found" << endl;
}
}
};
/// ========== USER MANAGER ============
/// ============ TASK ===============
class Task {
private:
string name;
string description;
public:
Task(string n, string desc) : name(n), description(desc) {} // name = n; desc = description
string getName()
{
return name;
}
string getDescription()
{
return description;
}
};
/// ============ TASK =============
/// ========== TASK MANAGER ===========
class TaskManager {
private:
vector<Task> tasks;
public:
void addTask()
{
string name, desc;
cout << "\n\t\t\t:: Project Add Section :: " << endl;
cout << "\t\t\tEnter project name: " << endl;
cin.ignore();
getline(cin, name);
cout << "\t\t\tEnter project description in short: " << endl;
getline(cin, desc);
Task newTask(name, desc);
tasks.push_back(newTask);
cout << "\t\t\tProject added successfully" << endl;
system("pause");
system("cls");
}
void displayTasks()
{
cout << "Tasks:" << endl;
for (auto &task : tasks)
{
cout << "Name: " << task.getName() << ", Description: " << task.getDescription() << endl;
}
}
};
/// ============ TASK MANAGER ===========
/// =========== MAIN FUNCTION ==============
int main()
{
UserManager usermanage;
AdminManager adminmanage;
TaskManager taskmanage;
int c;
char d;
do {
cout << "\n\t\t Bangladesh Army University of Science & Technology" << endl;
cout << "\t\t\t PROJECT SUPERVISION SYSTEM (PSS)" << endl;
cout << "\t\t\t\t 1. Register User" << endl;
cout << "\t\t\t\t 2. Login User" << endl;
cout << "\t\t\t\t 3. Logout User" << endl;
cout << "\t\t\t\t 4. Login Admin" << endl;
cout << "\t\t\t\t 5. Logout Admin" << endl;
cout << "\t\t\t\t 6. My Profile" << endl;
cout << "\t\t\t\t 7. Exit" << endl;
cout << "Enter your Choice: ";
cin >> c;
switch (c)
{
case 1:
{
usermanage.RegisterUser();
break;
}
case 2:
{
string name, password;
int id;
cout << "Name: ";
cin >> name;
cout << "ID: ";
cin >> id;
cout << "Password: ";
cin >> password;
usermanage.loginUser(name, id, password);
system("pause");
system("cls");
break;
}
case 3:
{
usermanage.LogoutUser();
break;
}
case 4:
{
string n;
int key;
cout << "Name: " << endl;
cin >> n;
cout << "Admin Code: " << endl;
cin >> key;
adminmanage.adminLogin(n, key);
bool backToMainMenu = false;
int abc;
do
{
cout << "\n\t\t\t Admin Options" << endl;
cout << "\t\t\t 1. Registered Students" << endl;
cout << "\t\t\t 2. Project List" << endl;
cout << "\t\t\t 3. Go back" << endl; // Added option to go back
cout << "Enter your choice: ";
cin >> abc;
switch (abc)
{
case 1:
{
if (adminmanage.loggedIndex == -1)
{
cout << "Please log in as admin first." << endl;
break;
}
if (!usermanage.users.empty())
{
cout << "\t\t\t========= Registered Students =============" << endl;
for (int i = 0; i < usermanage.users.size(); i++)
{
cout << "\n\n-----------------------------" << endl;
cout << "Name: " << usermanage.users[i].getName() << endl;
cout << "ID: " << usermanage.users[i].getId() << endl;
cout << "Department: " << usermanage.users[i].getDept() << endl;
cout << "Section: " << usermanage.users[i].getSection() << endl;
cout << "Batch: " << usermanage.users[i].getBatch() << endl;
cout << "-----------------------------" << endl;
cout << endl;
}
}
else
{
cout << "No registered students." << endl;
}
break;
}
case 2:
taskmanage.displayTasks();
break;
case 3: // If the admin chooses to go back
backToMainMenu = true; // Set flag to true to exit the loop
break;
default:
cout << "Invalid choice" << endl;
break;
}
}
while (!backToMainMenu);
break;
}
case 5:
{
adminmanage.logoutAdmin();
break;
}
case 6:
{
if (usermanage.loggedIndex == -1)
{
cout << "Please login first." << endl;
break;
}
string name;
cout << "Enter your name: ";
cin >> name;
usermanage.displayProfile(name);
bool backToMainMenu = false;
int cdc;
cout << endl;
cout << "\t\t\t === OTHER OPTIONS ===" << endl;
cout << "\t\t\t 1. Edit Profile" << endl;
cout << "\t\t\t 2. Add Task" << endl;
cout << "\t\t\t 3. Go Back" << endl;
cout << "Enter your choice: ";
cin >> cdc;
switch (cdc)
{
case 1:
{
char choice;
cout << "Do you want to edit your profile? (y/n): ";
cin >> choice;
if (choice == 'y' || choice == 'Y')
{
usermanage.EditProfile(name);
}
break;
}
case 2:
{
taskmanage.addTask();
break;
}
default:
break;
}
break;
}
case 7: {
cout << "Thanks for using the system" << endl;
d = 'n' || 'N';
break;
}
}
cout << "Continue? [y/n]" << endl;
cin >> d;
}
while (d == 'y' || d == 'Y');
}
/// =========== MAIN FUNCTION =================