Example #1
0
	void Registrar::enrollStudentInCourse(const std::string& studentName, const std::string& courseName) {
        Student* student = nullptr;
        Course* course = nullptr;

        for (size_t i = 0; i < students.size(); i++) {
            if (students[i]->getName() == studentName) {
                student = students[i];
            }
        }

        for (size_t i = 0; i < courses.size(); i++) {
            if (courses[i]->getName() == courseName) {
                course = courses[i];
            }
        }

        if (student != nullptr && course != nullptr) {
            student->addCourse(course);
            course->addStudent(student);
        } else {
            cerr << "Unable to find student or course when enrolling student" << endl;
        }
	}