コード例 #1
0
        public void printTimetable(string _professorName, TimetableCourses _courses, TimetableRooms _rooms)
        {
            string[] dayNames = { "Monday", "Thuesday", "Wednesday", "Thursday", "Friday" };
            Dictionary <string, List <Dozenti> >[] timesOfDaysDozenti = { this.blocksOfMonday, this.blocksOfThuesday, this.blocksOfWednesday, this.blocksOfThursday, this.blocksOfFriday };
            for (int day = 0; day < timesOfDaysDozenti.Length; day++)
            {
                for (int block = 1; block < 7; block++)
                {
                    for (int i = 0; i < timesOfDaysDozenti[day][block + ".Block"].Count; i++)
                    {
                        Dozenti dozent = timesOfDaysDozenti[day][block + ".Block"][i];

                        if (dozent.name == _professorName)
                        {
                            Console.WriteLine(dayNames[day] + ": " + block + ".Block: " +
                                              _courses.days[dayNames[day]][block + ".Block"][i].name + ": " +
                                              _rooms.days[dayNames[day]][block + ".Block"][i].roomnumber);
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void insertObjectsInTimetable(List <Courses> _listCourses, TimetableDozenti _timetableDozenti)
        {
            Dictionary <string, List <Courses> >[] blocksOfTheWeekCourses = { this.blocksOfMonday, this.blocksOfThuesday, this.blocksOfWednesday, this.blocksOfThursday, this.blocksOfFriday };
            Dictionary <string, List <Dozenti> >[] blocksOfTheWeekDozenti = { _timetableDozenti.blocksOfMonday, _timetableDozenti.blocksOfThuesday, _timetableDozenti.blocksOfWednesday, _timetableDozenti.blocksOfThursday, _timetableDozenti.blocksOfFriday };

            for (int day = 0; day < blocksOfTheWeekDozenti.Length; day++)
            {
                for (int block = 1; block < 7; block++)
                {
                    for (int i = 0; i < blocksOfTheWeekDozenti[day][block + ".Block"].Count; i++)
                    {
                        Dozenti dozent = blocksOfTheWeekDozenti[day][block + ".Block"][i];
                        for (int j = 0; j < _listCourses.Count; j++)
                        {
                            if (_listCourses[j].professor == dozent.name)
                            {
                                bool existing = false;
                                for (int k = 0; k < blocksOfTheWeekCourses[day][block + ".Block"].Count; k++)
                                {
                                    if (blocksOfTheWeekCourses[day][block + ".Block"][k].professor == dozent.name)
                                    {
                                        existing = true;
                                        break;
                                    }
                                }
                                if (existing == false)
                                {
                                    blocksOfTheWeekCourses[day][block + ".Block"].Add(_listCourses[j]);
                                    _listCourses.Remove(_listCourses[j]);
                                }
                            }
                        }
                    }
                }
            }
        }