-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSchool.cpp
More file actions
30 lines (26 loc) · 876 Bytes
/
Copy pathSchool.cpp
File metadata and controls
30 lines (26 loc) · 876 Bytes
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
// School.cpp
#include "School.h"
void School::admitStudent(const Student& student) {
students.push_back(student);
}
void School::createCourse(const std::string& name, int code) {
courses.push_back(Course(name, code));
}
void School::enrollStudentInCourse(const Student& student, int courseCode) {
for (auto& course : courses) {
if (course.getCode() == courseCode) {
course.enrollStudent(student);
return;
}
}
std::cout << "Course with code " << courseCode << " not found." << std::endl;
}
void School::displayEnrolledStudentsInCourse(int courseCode) const {
for (const auto& course : courses) {
if (course.getCode() == courseCode) {
course.displayEnrolledStudents();
return;
}
}
std::cout << "Course with code " << courseCode << " not found." << std::endl;
}