Beispiel #1
0
        public string GetTableForCohort(string userInput)
        {
            Cohort cohort = GetCohortByName(userInput);

            if (cohort == null)
            {
                return($"Cohort {userInput} not found");
            }

            StringBuilder sb = new StringBuilder($"Timetable for {userInput}:\n");

            foreach (Block block in completeTable)
            {
                if (block != null && block.lecturer != null && block.cohort == cohort)
                {
                    sb.Append($"{Block.getDayname(block.day)}, {Block.getTime(block.number)}: {block.courseName} in {block.room.name} with {block.lecturer.name}\n");
                }
            }
            return(sb.ToString());
        }
Beispiel #2
0
        public string GetOptionalCourses(string userInput)
        {
            Cohort cohort = GetCohortByName(userInput);

            if (cohort == null)
            {
                return($"Cohort {userInput} not found");
            }

            StringBuilder sb = new StringBuilder();

            sb.Append($"Optional courses available for {userInput}:\n");

            foreach (Lecturer lecturer in lecturerList)
            {
                if (lecturer.optionalCoursesOffered != null)
                {
                    foreach (OptionalCourse optionalCourse in lecturer.optionalCoursesOffered)
                    {
                        for (int i = 0; i < roomList.Count; i++)
                        {
                            if (completeTable[optionalCourse.day, optionalCourse.blockNumber, i].cohort != cohort)
                            {
                                sb.Append($"{Block.getDayname(optionalCourse.day)}, {Block.getTime(optionalCourse.blockNumber)}: {optionalCourse.name} in {optionalCourse.roomName} with {lecturer.name}\n");
                                break;
                            }
                        }
                    }
                }
            }
            if (sb.Length < 40)
            {
                return("No Optional Courses found for your TimeTable");
            }
            return(sb.ToString());
        }
Beispiel #3
0
 private void SaveCourseIntoNextAvailableBlock(Major major, Course course, Lecturer lecturer, Cohort cohort)
 {
     foreach (Block block in completeTable)
     {
         // Check if Block is used
         try {
             if (block.courseName == null && block.room.capacity >= cohort.students && lecturer.availableAt(block.day, block.number) && hasEquipment(block.room, course))
             {
                 block.major      = major;
                 block.courseName = course.name;
                 block.lecturer   = lecturer;
                 block.cohort     = cohort;
                 lecturer.isAbsentAt(block.day, block.number);
                 return;
             }
         } catch (System.NullReferenceException) {
             if (lecturer == null)
             {
                 // Some Lecturers are not yet entered into json-data
             }
         }
     }
 }