-
Notifications
You must be signed in to change notification settings - Fork 1
/
Department.cpp
138 lines (116 loc) · 4.02 KB
/
Department.cpp
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
#include<iostream>
#include<stdlib.h>
#include"Department.h"
using namespace std;
// Declaring and initializing static integer count variables //
int static countStudentName = 0;
int static countStudentID = 0;
int static countTeacherName = 0;
int static countTeacherID = 0;
int static countCourseName = 0;
int static countCourseID = 0;
Department::Department(string ID, string name)
{
// Initializing the ID of the department from the specified parameter if valid //
if (ID[0] == '-')
{
departmentID = "N/A";
}
else
{
departmentID = ID;
}
// Initializing the name of the department from the specified parameter //
departmentName = name;
}
// Defining the function that will assign a course to the department //
void Department::setCourse(string name, string id)
{
// Assigning the name of the course to the array index created for that function //
courseNameInDep[countCourseName] = name;
// Assigning the ID of the course to the array index created for that function //
courseIDInDep[countCourseID] = id;
// Incrementing counters //
countCourseName++;
countCourseID++;
}
// Defining the function that will assign a teacher to the department //
void Department::setTeacher(string name, string id)
{
// Assigning the name of the teacher to the array index created for that function //
teacherNameInDep[countTeacherName] = name;
// Assigning the ID of the teacher to the array index created for that function //
teacherIDInDep[countTeacherID] = id;
// Incrementing counters //
countTeacherName++;
countTeacherID++;
}
// Defining the function that will assign a student to the department //
void Department::setStudent(string name, string id)
{
// Assigning the name of the student to the array index created for that function //
studentNameInDep[countStudentName] = name;
// Assigning the ID of the student to the array index created for that function //
studentIDInDep[countStudentID] = id;
// Incrementing counters //
countStudentName++;
countStudentID++;
}
// Defining a function to access a private data member //
string Department::getDepartmentID()
{
// Returning the departmentID //
return departmentID;
}
// Defining the print function for all the teachers //
void Department::printAllTeachers()
{
// Printing an extra white space for styling purposes //
cout << "\n";
// Establishing a for loop that will run through all the elements of the array needed //
for (int i = 0; i < countTeacherID; i++)
{
// Checking if the current index of the array is empty //
if (teacherIDInDep[i] != "")
{
// Printing the required information for the teahcers in the department //
cout << teacherIDInDep[i] << " - " << teacherNameInDep[i] << endl;
}
}
}
// Defining the print function for all the students //
void Department::printAllStudents()
{
// Printing an extra white space for styling purposes //
cout << "\n";
// Establishing a for loop that will run through all the elements of the array needed //
for (int i = 0; i < countStudentID; i++)
{
// Checking if the current index of the array is empty //
if (studentIDInDep[i] != "")
{
// Printing the required information for the students in the department //
cout << studentIDInDep[i] << " - " << studentNameInDep[i] << endl;
}
}
}
// Defining the print function for all the courses //
void Department::printAllCourses()
{
// Printing an extra white space for styling purposes //
cout << "\n";
// Establishing a for loop that will run through all the elements of the array needed //
for (int i = 0; i < countCourseID; i++)
{
// Checking if the current index of the array is empty //
if (courseIDInDep[i] != "")
{
// Printing the required information for the courses in the department //
cout << courseIDInDep[i] << " - " << courseNameInDep[i] << endl;
}
}
}
Department::~Department()
{
// Empty body constructor //
}