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

Password:

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

Ocoursea.cpp

Go to the documentation of this file.
00001 //Filename    : OCOURSEA.CPP
00002 //Description : CourseArray Class Definition
00003 
00004 #include <ALL.H>
00005 #include <OMATH.H>
00006 #include <OSYS.H>
00007 #include <OFINANCE.H>
00008 #include <OINFO.H>
00009 #include <OCOURSE.H>
00010 
00011 //--------- Define static variables ---------//
00012 
00013 static char depthArray[] =
00014 { DEPTH_D1, DEPTH_D1, DEPTH_D1, DEPTH_D2, DEPTH_D2, DEPTH_D3, DEPTH_GR };
00015 
00016 static char focusArray[] =
00017 { FOCUS_LD, FOCUS_M, FOCUS_UD, FOCUS_M, FOCUS_UD, FOCUS_UD, FOCUS_GR };
00018 
00019 //----------- Begin of function CourseArray Constructor -----//
00021 CourseArray::CourseArray() : DynArrayB(sizeof(Course), 100, DEFAULT_REUSE_INTERVAL_DAYS) {
00022     //## fred 1019 ##//
00023     memset(course_enrollments, 0, sizeof(course_enrollments));
00024 
00025     // 1218
00026     memset(experienced_class_size, 0, sizeof(experienced_class_size));
00027 
00028 #if(GAME_VERSION>=200)
00029     memset(outsourcing_credits_history, 0, sizeof(outsourcing_credits_history));
00030 #endif
00031 }
00032 
00033 //------------- End of function CourseArray Constructor -----//
00034 
00035 //----------- Begin of function CourseArray Destructor ------//
00037 CourseArray::~CourseArray() {
00038 }
00039 
00040 //------------- End of function CourseArray Destructor ------//
00041 
00042 //--------- Begin of function CourseArray::add ---------//
00043 
00044 void CourseArray::add(Course *newCourse) {
00045     linkin(newCourse);
00046 
00047     ((Course*)get())->course_recno = recno();
00048 }
00049 
00050 //----------- End of function CourseArray::add -----------//
00051 
00052 //--------- Begin of function CourseArray::del ---------//
00053 
00054 void CourseArray::del(int recNo) {
00055     linkout(recNo);
00056 }
00057 
00058 //----------- End of function CourseArray::del -----------//
00059 
00060 //--------- Begin of function CourseArray::get_depth ---------//
00064 int CourseArray::get_depth(int depthFocusId) {
00065     return depthArray[depthFocusId];
00066 }
00067 
00068 //----------- End of function CourseArray::get_depth -----------//
00069 
00070 //--------- Begin of function CourseArray::get_focus ---------//
00074 int CourseArray::get_focus(int depthFocusId) {
00075     return focusArray[depthFocusId];
00076 }
00077 
00078 //----------- End of function CourseArray::get_focus -----------//
00079 
00080 //--------- Begin of function CourseArray::get_course ---------//
00084 Course* CourseArray::get_course(int courseDepth, int courseFocus, int teachingMethod) {
00085     for( int i=0 ; i<MAX_COURSE_DEPTH_FOCUS ; i++ ) {
00086         if( depthArray[i] == courseDepth && focusArray[i] == courseFocus ) {
00087             int courseRecno = i * MAX_TEACHING_METHOD + teachingMethod + 1;
00088 
00089             return operator[](courseRecno);
00090         }
00091     }
00092 
00093     err_here();
00094 
00095     return NULL;
00096 }
00097 
00098 //----------- End of function CourseArray::get_course -----------//
00099 
00100 //--------- Begin of function CourseArray::next_trimester ---------//
00105 void CourseArray::next_trimester() {
00106     //--- reset course variables in a new trimester ---//
00107 
00108     Course* coursePtr;
00109 
00110     for( int i=size() ; i>0 ; i-- ) {
00111         coursePtr = operator[](i);
00112 
00113         coursePtr->next_trimester();
00114     }
00115 }
00116 
00117 //----------- End of function CourseArray::next_trimester -----------//
00118 
00119 //#### begin fred 1019 ####//
00120 //--------- Begin of function CourseArray::next_day ---------//
00124 #if(GAME_VERSION>=200)
00125 void CourseArray::next_day(int initial)
00126 #else
00127     void CourseArray::next_day()
00128 #endif
00129 {
00130     if ( info.game_day == 1 ) {
00131         // start of a year
00132         if ( info.game_month == finance.fiscal_year_start_month )
00133             memset(course_enrollments, 0, sizeof(course_enrollments));
00134     }
00135 
00136     // start of a trimester
00137     if ( info.is_begin_trimester() ) {
00138         //--------  calc course enrollments for facility office --------//
00139 
00140         int i, enrollments[MAX_TEACHING_METHOD];
00141 
00142         memset(enrollments, 0, sizeof(enrollments));
00143 
00144         for (i=size(); i>0; i--) {
00145             Course* cPtr = this->operator[](i);
00146             enrollments[cPtr->teaching_method] = cPtr->convention_student_count;
00147         }
00148 
00149         // should be the maximum trimestrer enrollment over the three trimesters last year
00150 
00151         for ( i=0; i<MAX_TEACHING_METHOD; i++) {
00152             if ( course_enrollments[i] < enrollments[i] ) {
00153                 course_enrollments[i] = enrollments[i];
00154             }
00155         }
00156 
00157 #if(GAME_VERSION>=200)
00158         if ( !initial )
00159 #endif
00160             update_history();
00161     }
00162 }
00163 
00164 //----------- End of function CourseArray::next_day -----------//
00165 
00166 //------- Begin of function CourseArray::update_history -----//
00167 
00168 void CourseArray::update_history() {
00169     int sz = sizeof(class_section_count);
00170 
00171     memset(class_section_count, 0, sz);
00172     memset(convention_student_count, 0, sz);
00173     memset(average_class_size, 0, sz);
00174     memset(normal_class_size, 0, sz);
00175 
00176     memset(size_deviation, 0, sz);
00177     memset(admission_denied_count, 0, sz);
00178     memset(failure_count, 0, sz);
00179 
00180 #if(GAME_VERSION>=200)
00181     memset(outsourcing_credits, 0 ,sz);
00182 #endif
00183 
00184     /*
00185       Re: Q37a. hiring;and Q38
00186       Date: Wed, 9 Dec 1998 19:14:12 -0700
00187 
00188       Q38
00189 
00190       Q1. Re "How to calculate the item "experienced class size" on the screen Course
00191       for both "department" and "institution"?" This is just the average of the
00193       class sizes for the individual courses in the department or the
00194       institution. I.e, calculate (enrollment/number of primary sections) for
00195       each course and take the average. By "primary section" I mean to ignore the
00196       breakout sections for classes with breakouts: the breakouts don't enter the
00197       average. The "institution" number is the average for all courses in the
00198       instituion, not the average of the departmental averages.
00199     */
00200 
00201     shift_history(experienced_class_size, HISTORY_TRIMESTER_COUNT);
00202 
00203     //float total = 0;
00204     //int count = 0;
00205 
00206     for (int i=size(); i>0; i--) {
00207         Course* cPtr = this->operator[](i);
00208         int tm = cPtr->teaching_method;
00209         err_when(tm >= MAX_TEACHING_METHOD);
00210 
00211         class_section_count[tm] += cPtr->class_section_count;
00212         convention_student_count[tm] += cPtr->convention_student_count;
00213         // 0308 use = instead of +=
00214         normal_class_size[tm] = cPtr->normal_class_size();
00215         admission_denied_count[tm] += cPtr->admission_denied_count;
00216         failure_count[tm] += cPtr->failure_count;
00217 
00218 #if(GAME_VERSION>=200)
00219         outsourcing_credits[tm] += cPtr->outsourcing_credits;
00220 #endif
00221 
00222         if ( tm != BREAKOUT_LAB ) {
00223             //                  total += math.safe_divide(cPtr->convention_student_count, cPtr->class_section_count);
00224             //                  count++;
00225         }
00226     }
00227 
00228     //experienced_class_size[THIS_TRIMESTER] = (int) math.safe_divide(total, (float) count);
00229 
00230     for(char t=0; t<MAX_TEACHING_METHOD; t++) {
00231 #if(GAME_VERSION>=200)
00232         outsourcing_credits[MAX_TEACHING_METHOD] += outsourcing_credits[t];
00233 #endif
00234 
00235 #if(GAME_VERSION>=200)
00236         if ( t == DISTANCE_LEARN_COURSE )             // Kenneth
00237             continue;
00238 #endif
00239 
00240         average_class_size[t] = (int) math.safe_divide(convention_student_count[t], class_section_count[t]);
00241 
00242         if( class_section_count[t] > 0 )
00243             size_deviation[t] = (int) math.safe_divide(100 * (average_class_size[t]-normal_class_size[t]), normal_class_size[t]);
00244         else
00245             size_deviation[t] = 0;                      // no deviation if there is no section.
00246 
00247         //0405
00248         experienced_class_size[THIS_TRIMESTER] += average_class_size[t];
00249 
00250         //----//
00251 
00252         class_section_count[MAX_TEACHING_METHOD] += class_section_count[t];
00253         convention_student_count[MAX_TEACHING_METHOD] += convention_student_count[t];
00254         //0405 average_class_size[MAX_TEACHING_METHOD] += average_class_size[t];
00255         normal_class_size[MAX_TEACHING_METHOD] += normal_class_size[t];
00256         // size_deviation[MAX_TEACHING_METHOD] += size_deviation[t];
00257         // fix in version 2 use weighted average (weight is class_section_count)
00258         size_deviation[MAX_TEACHING_METHOD] += size_deviation[t] * class_section_count[t];
00259         admission_denied_count[MAX_TEACHING_METHOD] += admission_denied_count[t];
00260         failure_count[MAX_TEACHING_METHOD] += failure_count[t];
00261     }
00262 
00263     //## chea begin 990525
00264 
00265     // 0405
00266     average_class_size[MAX_TEACHING_METHOD] = (int) math.safe_divide(convention_student_count[MAX_TEACHING_METHOD], class_section_count[MAX_TEACHING_METHOD]);
00267 
00268     if ( average_class_size[MAX_TEACHING_METHOD] <= 0)
00269         experienced_class_size[THIS_TRIMESTER] = experienced_class_size[THIS_TRIMESTER-1];
00270     else
00271         experienced_class_size[THIS_TRIMESTER] = average_class_size[MAX_TEACHING_METHOD];
00272 
00273     //## chea end 990525
00274 
00275     normal_class_size[MAX_TEACHING_METHOD] /= (MAX_TEACHING_METHOD-1);
00276 
00277     // size_deviation[MAX_TEACHING_METHOD] /= (MAX_TEACHING_METHOD-1);
00278     // fix in version 2 use weighted average (weight is class_section_count)
00279     if( class_section_count[MAX_TEACHING_METHOD] > 0 )
00280         size_deviation[MAX_TEACHING_METHOD] = (int)math.safe_divide( size_deviation[MAX_TEACHING_METHOD], class_section_count[MAX_TEACHING_METHOD] );
00281     else
00282         size_deviation[MAX_TEACHING_METHOD] = 0;
00283 
00284 #if(GAME_VERSION>=200)
00285     // after updating
00286     for(t=0; t<MAX_TEACHING_METHOD_N_TOTAL; t++) {
00287         shift_history(class_section_count_history[t], HISTORY_TRIMESTER_COUNT);
00288         class_section_count_history[t][THIS_TRIMESTER] = class_section_count[t];
00289         shift_history(convention_student_count_history[t], HISTORY_TRIMESTER_COUNT);
00290         convention_student_count_history[t][THIS_TRIMESTER] = convention_student_count[t];
00291         shift_history(size_deviation_history[t], HISTORY_TRIMESTER_COUNT);
00292         size_deviation_history[t][THIS_TRIMESTER] = size_deviation[t];
00293         shift_history(admission_denied_count_history[t], HISTORY_TRIMESTER_COUNT);
00294         admission_denied_count_history[t][THIS_TRIMESTER] = admission_denied_count[t];
00295         shift_history(failure_count_history[t], HISTORY_TRIMESTER_COUNT);
00296         failure_count_history[t][THIS_TRIMESTER] = failure_count[t];
00297 #if(GAME_VERSION>=200)
00298         shift_history( outsourcing_credits_history[t], HISTORY_TRIMESTER_COUNT);
00299         outsourcing_credits_history[t][THIS_TRIMESTER] = outsourcing_credits[t];
00300 #endif
00301     }
00302 #endif
00303 
00304 }
00305 
00306 //------- End of function CourseArray::update_history -----//
00307 
00308 // ##### Begin Marco ##### //
00309 #if(GAME_VERSION>=200)
00310 //--------- Begin of function CourseArray::save_initial_data ---------//
00311 void CourseArray::save_initial_data() {
00312     for (int i = 0; i < MAX_TEACHING_METHOD_N_TOTAL; i++) {
00313         initial_class_section_count[i] = class_section_count[i];
00314         initial_convention_student_count[i] = convention_student_count[i];
00315         initial_average_class_size[i] = average_class_size[i];
00316         initial_size_deviation[i] = size_deviation[i];
00317         initial_admission_denied_count[i] = admission_denied_count[i];
00318         initial_failure_count[i] = failure_count[i];
00319         initial_normal_class_size[i] = normal_class_size[i];
00320     }
00321 
00322     initial_experienced_class_size = experienced_class_size[HISTORY_TRIMESTER_COUNT-1];
00323 }
00324 
00325 //--------- End of function CourseArray::save_initial_data ---------//
00326 #endif
00327 // ##### End Marco ##### //
00328 
00329 #ifdef DEBUG
00330 
00331 //------- Begin of function CourseArray::operator[] -----//
00332 
00333 Course* CourseArray::operator[](int recNo) {
00334     Course* coursePtr = (Course*) get(recNo);
00335 
00336     if( !coursePtr )
00337         err.run( "CourseArray[] is deleted" );
00338 
00339     return coursePtr;
00340 }
00341 
00342 //--------- End of function CourseArray::operator[] ----//
00343 #endif
00344 
00345 #if(GAME_VERSION>=200)
00346 int CourseArray::is_deleted(int recNo) {
00347     Course* coursePtr = (Course*) get(recNo);
00348 
00349     if(!coursePtr || !coursePtr->course_recno)
00350         return 1;
00351 
00352     return 0;
00353 }
00354 #endif

Generated on Fri Aug 23 01:37:20 2002 for VirtualU by doxygen1.2.17