bool BScStudent::hasStudentGraduated() // return 1 if the student Graduated by his points // { int intermediateCoursesPoints = 0; int sumPoints = 0; for (auto it = begin (getCourses()); it != end (getCourses()); ++it) { sumPoints += it->getCourse()->getCoursePoints(); // add all the regular points intermediateCoursesPoints += (it->getCourse()->getCourseLevel() == INTERMEDIATE ? it->getCourse()->getCoursePoints() : 0); } return (intermediateCoursesPoints >= 5 && sumPoints >= 20); //check if enought points }
REPLY* runTcre(COMMAND cnode,STUDENT *shead,COURSES *chead){ STUDENT *spointer; COURSES *cpointer; int i; REPLY *rtemp; int total = 0; if((rtemp = malloc(sizeof(REPLY))) == NULL){ fprintf(stderr,"Error occured with malloc.\n"); exit(1); } if((spointer = getStudent(shead,cnode.string)) !=NULL){ for(i = 0; i <MAX_CLASSES; i++){ if(spointer->courseIds[i] != -1){ //printf("index:%d,courseid:%d ",i,spointer->courseIds[i]); if((cpointer = getCourse(chead,spointer->courseIds[i])) != NULL){ total += cpointer->numCredits; // printf("numcredits:%d,total:%d\n",cpointer->numCredits,total); } } } rtemp->status = 1; rtemp->intValues = total; return rtemp; } rtemp->status = 0; rtemp->intValues = -1; return rtemp; }
REPLY* runGcre(COMMAND cnode,STUDENT *shead,COURSES *chead){ REPLY *rtemp; COURSES *cpointer; if((rtemp = malloc(sizeof(REPLY))) == NULL){ fprintf(stderr,"Error occured with malloc.\n"); exit(1); } if((cpointer = getCourse(chead,cnode.courseId)) !=NULL){ rtemp->status = 1; rtemp->intValues = cpointer->numCredits; return rtemp; } rtemp->status = 0; rtemp->intValues = -1; return rtemp; }
REPLY* runGsch(COMMAND cnode,STUDENT *shead,COURSES *chead){ REPLY *rtemp; COURSES *cpointer; if((rtemp = malloc(sizeof(REPLY))) == NULL){ fprintf(stderr,"Error occured with malloc.\n"); exit(1); } if((cpointer = getCourse(chead,cnode.courseId)) !=NULL){ rtemp->status = 1; strcpy(rtemp->string,cpointer->schedule); return rtemp; } rtemp->status = 0; strcpy(rtemp->string,"Error"); return rtemp; }
double OrbitalPilot::evaluateAction(SimFrame* frame, PilotAction action, int depth) { SimFrame* nextFrame = Simulator::computeNextFrame(frame, action.orientation, action.throttle); double score; if(depth <= 0){ score = evaluateFrame(nextFrame); } else { PilotAction nextAction = getCourse(nextFrame, depth-1); score = nextAction.score; } delete nextFrame; return score; }
REPLY* runNewc(COMMAND cnode,STUDENT *shead,COURSES *chead){ REPLY *rtemp; COURSES *cpointer; COURSES *temp; if((temp = malloc(sizeof(COURSES))) == NULL){ fprintf(stderr,"Error occured with malloc.\n"); exit(1); } if((rtemp = malloc(sizeof(REPLY))) == NULL){ fprintf(stderr,"Error occured with malloc.\n"); exit(1); } if(cnode.numCredits <= 0){ rtemp->status = 0; return rtemp; } else if((getCourse(chead,cnode.courseId)) !=NULL){ rtemp->status = 0; return rtemp; } else{ temp->courseID = cnode.courseId; temp->numCredits = cnode.numCredits; temp->next = NULL; strcpy(temp->schedule,cnode.string); if(chead == NULL){ chead = temp; } else{ cpointer = chead; while(cpointer->next!=NULL){ cpointer = cpointer->next; } cpointer->next = temp; } } rtemp->status = 1; return rtemp; }
REPLY* runAddc(COMMAND cnode,STUDENT *shead,COURSES *chead){ REPLY *rtemp; int k; STUDENT *studentp; STUDENT *current; STUDENT *temp; COURSES *coursep; int i; if((rtemp = malloc(sizeof(REPLY))) == NULL){ fprintf(stderr,"Error occured with malloc"); exit(1); } if((coursep =getCourse(chead,cnode.courseId)) !=NULL){ if((studentp = getStudent(shead,cnode.string)) !=NULL){ k = 0; while(studentp->courseIds[k] != -1){ if(k >=MAX_CLASSES){ rtemp->status = 0; return rtemp; } if(studentp->courseIds[k] == cnode.courseId){ rtemp->status = 0; return rtemp; } k++; } studentp->courseIds[k] = cnode.courseId; studentp->numCourses++; rtemp->status = 1; return rtemp; } else if(studentp == NULL){ if((countStudents(shead))+1 >100){ rtemp->status = 0; return rtemp; } else{ current = shead; while(current->next !=NULL){ current = current->next; } if((temp = malloc(sizeof(STUDENT))) == NULL){ fprintf(stderr,"Error occured with maloc\n"); exit(1); } strcpy(temp->name,cnode.string); temp->numCourses = 1; temp->next = NULL; current->next = temp; for(i = 1; i < MAX_CLASSES;i++){ temp->courseIds[i] = -1; } temp->courseIds[0] = cnode.courseId; rtemp->status = 1; return rtemp; } } } else if(coursep == NULL){ rtemp->status = 0; return rtemp; } rtemp->status = 1; return rtemp; }
PilotAction OrbitalPilot::getCourse(SimFrame *frame) { return getCourse(frame, frame->config->params.searchDepth); }