-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentID.cpp
More file actions
65 lines (64 loc) · 2.42 KB
/
StudentID.cpp
File metadata and controls
65 lines (64 loc) · 2.42 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
#include"StudentID.h"
#include<windows.h>
#include<limits>
StudentRegistrationSystem::~StudentRegistrationSystem() {
std::cerr << "Destructor Runs" << std::endl;
};
void StudentRegistrationSystem::addStudent(int ID, const std::string& Name, const std::string& Course) {
StudentsData.emplace_back(std::make_tuple(ID, Name, Course));
}
void StudentRegistrationSystem::Display() {
std::cout << "Base Display (override in derived class)" << std::endl;
}
DisplayData::DisplayData(int id, const std::string& name, const std::string& course) {
addStudent(id, name, course);
}
void DisplayData::Display() {
for (auto& student : StudentsData) {
PrintAllElements(student);
}
}
int main() {
try {
DisplayData StudentA(25120327, "Lewis", "Software Engineering & Operating System");
while (true) {
Sleep(5000);
std::cout << "**** Student Registration System ****" << std::endl;
std::cout << "1. Add Student" << std::endl;
std::cout << "2. Display Students' Data" << std::endl;
std::cout << "3. Exit The Program" << std::endl;
std::cout << "Choose An Option: ";
int key;
std::cin >> key;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
if (key == 1) {
int ID;
std::string Name, Course;
std::cout << "Your ID: ";
std::cin >> ID;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
std::cout << "Your Name: ";
std::getline(std::cin, Name);
std::cout << "Your Study: ";
std::cin >> Course;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
StudentA.addStudent(ID, Name, Course);
}
else if (key == 2) {
StudentA.Display();
}
else if (key == 3) {
system("cls");
break;
}
else {
throw std::invalid_argument("Invalid Option");
break;
}
}
}
catch (const std::exception& e) {
std::cout << e.what();
}
return 0;
}