Hi guys. listar
I'm doing a program in "c + +" and I need one method that show one student in relation of your course and its disciplines
The function of the student get in a course is ok and the function of the disciplines get in a course too.
//in main, i created one list with all courses. This list is passed to allcourses with parameter.
list<course> listStudentCourses(Student stud, list<Course> allCourses) {
list<course> auxCourse;
auxCourse.clear();
Course courseObj;
for (list<Course>::iterator i = allCourses.begin(); i != allCourses.end(); i++) {
i->DisplayCourse();
if (i->checkStudent(stud)) {
courseObj.SetYear(i->GetYear());
courseObj.SetCode(i->GetCode());
courseObj.SetName(i->GetName());
courseObj.SetPrice(i->getPrice());
courseObj.SetCourseTime(i->GetCourseTime());
auxCourse.insert(auxCourse.end(), 1, courseObj);
}
}
return auxCourse;
}
CheckStudent is the function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
bool Course::checkStudent(Student stud) {
string air = stud.GetAr();
// get the academic registry
cout << "Student Air:" << air << endl;
// display of the Air stud.GetAr();
for (list<Student>::iterator i = stList.begin(); i != stList.end(); i++) {
// stlist is one list with all students.
string ArAux = i->GetAr();
cout << "i->Air:" << air << endl;
// display of the Ar ir->getArea();
if (air == ArAux) {
cout << "Student is present in this course" << endl;
returntrue;
}
}
cout << "Student are not in this course." << endl;
returnfalse;
}
When I run the program, it enters the checkStudent but never enters the comparison of academic registry (if (ra == Araux ){..}) always returns false.