Пример #1
0
 public CourseBlock(Professor prof_, Room room_, Course course_)
 {
     professor = prof_;
     room      = room_;
     course    = course_;
 }
Пример #2
0
 //check if the prof is teaching more than 2 classes in any given day
 public bool classesInDay(List <CourseBlock> list, Professor prof)
 {
     /* Time blocks
      * M |T |W |T |F |S |S
      * 0 |4 |0 |4 |14|14
      * 1 |5 |8 |11|15|18
      * 2 |6 |9 |12|16|19
      * 3 |7 |10|13|17|20
      */
     int[] days = { 0, 0, 0, 0, 0, 0 }; //6 teaching days
     foreach (CourseBlock block in list)
     {
         if (block.professor == prof)
         {
             if (block.time == 0)                         //first block on monday/wednesday
             {
                 days[0]++;                               //one class on monday
                 days[2]++;                               //one class on wednesday
             }
             else if (block.time >= 1 && block.time <= 3) //other classes on monday
             {
                 days[0]++;
             }
             else if (block.time == 4)                    //first block on tues/thursday
             {
                 days[1]++;                               //one class on tuesday
                 days[3]++;                               //one class on thursday
             }
             else if (block.time >= 5 && block.time <= 7) //other classes on tues
             {
                 days[1]++;
             }
             else if (block.time >= 8 && block.time <= 10) //other classes on wed
             {
                 days[2]++;
             }
             else if (block.time >= 11 && block.time <= 13) //other classes on wed
             {
                 days[3]++;
             }
             else if (block.time == 14)                     //first block on fri/sat
             {
                 days[4]++;                                 //one class on fri
                 days[5]++;                                 //one class on sat
             }
             else if (block.time >= 15 && block.time <= 17) //other classes on fri
             {
                 days[4]++;
             }
             else if (block.time >= 18 && block.time <= 20) //other classes on sat
             {
                 days[5]++;
             }
         }
     }
     for (int n = 0; n < 6; n++)
     {
         if (days[n] > 2)
         {
             return(false); //if teaching more than 2 blocks on any day return false
         }
     }
     return(true); //not teaching more than 2 blocks a day
 }