-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstructor.cpp
More file actions
91 lines (86 loc) · 2.56 KB
/
instructor.cpp
File metadata and controls
91 lines (86 loc) · 2.56 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
#include "instructor.h"
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
void instructor::seeWhoEnrolled() {
ifstream enrollFIle("enrolled.txt", ios::app);
cout << endl;
cout << "Course-No." << setw(10) << "Learners" << setw(20) << '\n';
cout << string(20, '-') << endl;
int id;
string name;
while (!enrollFIle.eof()) {
enrollFIle >> id >> name;
cout << id << setw(18);
cout << name << setw(20) << '\n';
}
enrollFIle.close();
}
void instructor::instructorMenu() {
while (true) {
cout << "\n1. Add a course." << endl;
cout << "2. Delete a course." << endl;
cout << "3. See all courses." << endl;
cout << "4. See who enrolled." << endl;
cout << "5. Log out." << endl;
cout << "Select an option: ";
int option;
cin >> option;
switch (option) {
case 1:
instructor::addCourses();
cout << "\nCourse Added Successfully!" << endl;
break;
case 2:
instructor::deleteCourses();
cout << "\nThe selected course is Deleted!\n";
instructor::copyFile();
break;
case 3:
instructor::showCourses();
break;
case 4:
instructor::seeWhoEnrolled();
break;
case 5:
return;
}
}
}
void instructor::registration() {
std::srand(std::time(0));
int random_number = 1000 + (std::rand() % (9000));
cin.ignore();
cout << "\nEnter your name: ";
getline(cin, instructorName);
cout << "\nWe will send you an OTP.\nPlease Provide your E-mail/Phone no: ";
cin >> contact;
cout << "\nYour OTP is: " << random_number << endl;
cout << "Confirm OTP: ";
cin >> insPassword;
if (insPassword != random_number) {
cout << "Incorrect OTP!" << endl;
return;
}
cout << "Preserve this OTP for login in this session." << endl;
cout << "\nWelcome " << instructorName << " as an Instructor <3" << endl;
um[random_number] = instructorName;
instructorMenu();
}
void instructor::login() {
cout << "\nEnter your 4-digit OTP: ";
cin >> insPassword;
for (auto i : um) {
if (insPassword == i.first) {
cout << "\nWelcome " << i.second << endl;
instructorMenu();
return;
}
}
cout << "\nIncorrect OTP! or The session expired!" << endl;
cout << "To log into the new session please register again..\n" << endl;
}