Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

Ostudena.cpp Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Ostudena.cpp

Go to the documentation of this file.
00001 //Filename    : OSTUDENA.CPP
00002 //Description : Student Array Class Definition
00003 
00004 #include <OSYS.H>
00005 
00006 #include <OINFO.H>
00007 #include <OPSCHOOL.H>
00008 #include <ODEPT.H>
00009 #include <OFINANCE.H>
00010 #include <OSTUDENT.H>
00011 #include <OENROLL.H>
00012 
00013 //----------- Begin of function StudentArray Constructor -----//
00015 StudentArray::StudentArray() : DynArrayB(sizeof(Student), 200, DEFAULT_REUSE_INTERVAL_DAYS) {
00016     student_count=0;
00017 
00018     memset(talent_academic_all, 0, sizeof(talent_academic_all));
00019     memset(performance_academic_ug, 0, sizeof(performance_academic_ug));
00020 
00021     memset(talent_academic, 0, sizeof(talent_academic));
00022     memset(talent_extracurricular, 0, sizeof(talent_academic));
00023     memset(talent_athletics, 0, sizeof(talent_academic));
00024 
00025     memset(satisfaction_academic, 0, sizeof(talent_academic));
00026     memset(satisfaction_student_life, 0, sizeof(talent_academic));
00027     memset(satisfaction_athletics, 0, sizeof(talent_academic));
00028     memset(satisfaction_overall, 0, sizeof(satisfaction_overall));
00029 
00030     memset(time_to_degree, 0, sizeof(time_to_degree));
00031     memset(dropout_rate, 0, sizeof(dropout_rate));
00032 
00033     // ### begin Gilbert 05/06/2001 #####//
00034     memset(fake_disp_time_to_degree, 0, sizeof(fake_disp_time_to_degree) );
00035     // ### end Gilbert 05/06/2001 #####//
00036 
00037     memset(bachelor_degree,0,sizeof(doctor_degree));
00038 #if(GAME_VERSION>=200)
00039     memset(non_ug_bachelor_degree,0,sizeof(doctor_degree));
00040 #endif
00041     memset(master_degree,0,sizeof(doctor_degree));
00042     memset(doctor_degree,0,sizeof(doctor_degree));
00043 
00044     memset(time_to_degree_cumm,0,sizeof(time_to_degree_cumm));
00045     memset(cur_dropout,0,sizeof(cur_dropout));
00046     memset(ave_entering_class,0,sizeof(ave_entering_class));
00047 
00048     cur_bachelor_degree = 0;
00049 #if(GAME_VERSION>=200)
00050     cur_non_ug_bachelor_degree = 0;
00051 #endif
00052     cur_master_degree = 0;
00053     cur_doctor_degree = 0;
00054 
00055 #if(GAME_VERSION>=200)
00056     for ( int i=0; i<4; i++ ) {
00057         last_year_degree[i] = 0;
00058         last_year_dropout[i] = 0;
00059     }
00060 #endif
00061 
00062     ave_time_to_graduation_for_ug = 0;
00063 }
00064 
00065 //------------- End of function StudentArray Constructor -----//
00066 
00067 //----------- Begin of function StudentArray Destructor ------//
00069 StudentArray::~StudentArray() {
00070     //----------------------------------//
00071     for( int i=size() ; i>0 ; i-- ) {
00072         if( !is_deleted(i) )
00073             del(i);
00074     }
00075 
00076     //----------------------------------//
00077 }
00078 
00079 //------------- End of function StudentArray Destructor ------//
00080 
00081 //--------- Begin of function StudentArray::add ---------//
00082 
00083 int StudentArray::add(char studentLevel, char yearInProgram, char genderEthnicGroup, char stuSeg, char major, int finAid, float* talentArr) {
00084     Student student;
00085 
00086     student.init(studentLevel, yearInProgram, genderEthnicGroup, stuSeg, major, finAid, talentArr );
00087 
00088     linkin(&student);
00089 
00090     ((Student*)get())->student_recno = recno();
00091 
00092     student_count++;
00093 
00094     return recno();
00095 }
00096 
00097 //----------- End of function StudentArray::add -----------//
00098 
00099 //--------- Begin of function StudentArray::del ---------//
00100 
00101 void StudentArray::del(int recNo) {
00102 #if(GAME_VERSION>=200)
00103     // BUG FIXED in Version 2.0
00104     Student *ptr = (Student*) get(recNo);
00105 #else
00106     Student *ptr = (Student*) get_ptr(recNo);
00107 #endif
00108 
00109     // avoid bug 2107
00110     if(!ptr)
00111         return;                                       // temp use
00112     //  err_when(!ptr);
00113 
00114     //##### begin fred 980915 #####//
00115     student_count--;
00116     //##### end fred 980915 #####//
00117     linkout(recNo);
00118 }
00119 
00120 //----------- End of function StudentArray::del -----------//
00121 
00122 //--------- Begin of function StudentArray::is_deleted ---------//
00123 
00124 int StudentArray::is_deleted(int recNo) {
00125     Student* studentPtr = (Student*) get(recNo);
00126     if( studentPtr == NULL )
00127         return 1;
00128     return studentPtr->student_recno == 0;
00129 }
00130 
00131 //----------- End of function StudentArray::is_deleted -----------//
00132 
00133 #ifdef DEBUG
00134 
00135 //------- Begin of function StudentArray::operator[] -----//
00136 
00137 Student* StudentArray::operator[](int recNo) {
00138     Student* StudentPtr = (Student*) get(recNo);
00139 
00140     if( !StudentPtr )
00141         err.run( "StudentArray[] is deleted" );
00142 
00143     return StudentPtr;
00144 }
00145 
00146 //--------- End of function StudentArray::operator[] ----//
00147 #endif
00148 
00149 //------------------------------------------------------------//
00150 //------------------------------------------------------------//
00151 //------------------------------------------------------------//
00152 //------------------------------------------------------------//
00153 //------------------------------------------------------------//
00154 
00155 //--------- Begin of function StudentArray::next_day ---------//
00157 void StudentArray::next_day() {
00158     //----- call individual student's next_day() function ----//
00159 
00160     for( int i=size() ; i>0 ; i-- ) {
00161         if( is_deleted(i) )
00162             continue;
00163 
00164         operator[](i)->next_day();
00165     }
00166 
00167     //##### begin fred 980819 #####//
00168     //----------------------------------------//
00169     // start of a month
00170     if ( info.game_day == 1 ) {
00171         //## 071299 chea 1.12.1
00172         //     update_history(UPDATE_MONTH);
00173 
00174         // start of a year
00175         if ( info.game_month == finance.fiscal_year_start_month )
00176             update_history(UPDATE_YEAR);
00177         //## 071299 chea 1.12.1
00178         else
00179             update_history(UPDATE_MONTH);
00180 
00181     }
00182 
00183     //##### end fred 980819 #####//
00184 }
00185 
00186 //----------- End of function StudentArray::next_day -----------//
00187 
00188 //--------- Begin of function StudentArray::next_trimester ---------//
00192 void StudentArray::next_trimester() {
00193 
00194     for( int i=size() ; i>0 ; i-- ) {
00195         if( is_deleted(i) )
00196             continue;
00197 
00198         operator[](i)->next_trimester();
00199         sys.yield();
00200     }
00201 
00202     //----- select courses for the new trimester ------//
00203 
00204     //### fred 980916 ###//
00205     // select_cours() runs after next_trimester() which handle change of major and drop out//
00206 
00207     //select_cours();           // remove this because it should be called after enrollment
00208 }
00209 
00210 //----------- End of function StudentArray::next_trimester -----------//
00211 
00212 //--------- Begin of function StudentArray::select_course ---------//
00221 void StudentArray::select_course(int ignoreFaculty) {
00222     //-- select courses for students in various student levels based on the priority set by the user --//
00223 
00224     //  int studentCount = packed_size();               // 990302  BUGHERE should use size() instead
00225 
00226     int studentCount = size();                      //## chea 300899 used size() instead
00227     //   info.debug_enroll3 = packed_size();    //## chea 270899
00228 
00229     for( int i=0 ; i<MAX_STUDENT_LEVEL ; i++ ) {
00230         int studentLevel = player_school.course_match_order[i];
00231         int studentRecno = m.random(studentCount);
00232 
00233         for( int y=0 ; y<studentCount ; y++ ) {
00234             if( ++studentRecno > studentCount )
00235                 studentRecno = 1;
00236 
00237             if( is_deleted(studentRecno) )
00238                 continue;
00239 
00240             Student* studentPtr = operator[](studentRecno);
00241 
00242             if( studentPtr->student_level != studentLevel )
00243                 continue;
00244 
00245             studentPtr->file_course_id=0;
00246             studentPtr->select_course(ignoreFaculty);
00247 
00248             //                  info.debug_enroll2++; //## chea 270899
00249         }
00250     }
00251 
00252     //--- reset counter variables after completing course selection for the trimester ---//
00253 
00254     // if this is the last trimester in a year, reset annual variables
00255     if( player_school.cur_trimester == LAST_TRIMESTER ) {
00256         for( int i=studentCount ; i>0 ; i-- ) {
00257             if( is_deleted(i) )
00258                 continue;
00259 
00260             Student* studentPtr = operator[](i);
00261 
00262             studentPtr->total_elective_course_this_year = 0;
00263         }
00264     }
00265 
00266 }
00267 
00268 //---------- End of function StudentArray::select_course ----------//
00269 
00270 //--------- Begin of function StudentArray::init_course ---------//
00279 void StudentArray::init_course(int processYearInProgram) {
00280     err_here();                                     // 990413---------------------------------------
00281 
00282     int studentCount = size();
00283     int studentRecno = m.random(studentCount);
00284 
00285     for( int thisTrimester=FIRST_TRIMESTER ; thisTrimester<=LAST_TRIMESTER ; thisTrimester++ ) {
00286         //---- call course_select() for all students in this department ----//
00287 
00288         for( int i=0 ; i<studentCount ; i++ ) {
00289             if( ++studentRecno > studentCount )
00290                 studentRecno = 1;
00291 
00292             if( is_deleted(studentRecno) )
00293                 continue;
00294 
00295             Student* studentPtr = operator[](studentRecno);
00296 
00297             //----------------------------------------//
00298 
00299             if( studentPtr->year_in_program==1 )        // no need to initialize courses for students in the first year
00300                 continue;
00301 
00302             if( studentPtr->student_level == MASTER ) { // no course selection for non-matriculated. Master student only has one year, so no initialization also
00303                 //studentPtr->student_level == NON_MATRICULATED )               //0107
00304                 continue;
00305             }
00306 
00307             //---- clip the year in program to the standard year for easy handling ----//
00308 
00309             int yearInProgram, maxYearInProgram;
00310 
00311             switch( studentPtr->student_level ) {
00312             case UG_TRADITION:
00313             case UG_NONTRADITION:
00314             case DISTANCE_LEARN:                      // 0107
00315                 maxYearInProgram = BACHELOR_YEAR_COUNT;
00316                 break;
00317 
00318             case DOCTOR:
00319                 maxYearInProgram = DOCTOR_YEAR_COUNT;
00320                 break;
00321             }
00322 
00323             yearInProgram = min( studentPtr->year_in_program, maxYearInProgram );
00324 
00325             //--- only process students whose year in program is the same as processYearInProgram ---//
00326 
00327             if( yearInProgram == processYearInProgram ) {
00328                 //-- if the current year_in_program exceeds the max, set it to max and restore the original later --//
00329 
00330                 int saveYearInProgram=0;
00331 
00332                 if( studentPtr->year_in_program > maxYearInProgram ) {
00333                     saveYearInProgram = studentPtr->year_in_program;
00334                     studentPtr->year_in_program = maxYearInProgram;
00335                 }
00336 
00337                 //----- select course now ------//
00338 
00339                 studentPtr->select_course(1);             // 1-ignore faculty resource constraints.
00340 
00341                 //----- restore the original year in program -----//
00342 
00343                 if( saveYearInProgram )
00344                     studentPtr->year_in_program = saveYearInProgram;
00345 
00346                 //--- reset yearly counter if this is the last trimester ---//
00347 
00348                 if( thisTrimester==LAST_TRIMESTER )
00349                     studentPtr->total_elective_course_this_year = 0;
00350             }
00351         }
00352 
00353         //------ reset vars for all courses in this department ------//
00354 
00355         Department* deptPtr = department_array[department_recno];
00356 
00357         for( i=deptPtr->course_array.size() ; i>0 ; i-- ) {
00358             deptPtr->course_array[i]->reset_vars();     // reset it so that we can call course later selection without previous constraints.
00359         }
00360     }
00361 }
00362 
00363 //----------- End of function StudentArray::init_course -----------//

Generated on Fri Aug 23 01:38:27 2002 for VirtualU by doxygen1.2.17