Exemple #1
0
    //Elev1
    // Start is called before the first frame update
    void Start()
    {
        laerer1 = new Laerer("Lars", bilde1, "Matte");
        laerer2 = new Laerer("Otto", bilde1, "Nork");
        elev1   = new Elev("rn", bilde1, 7);

        for (int i = 0; i < 500; i++)
        {
            mineLaerere.Add(new Laerer("Arne" + (i + 1), bilde1, "IT"));
        }

        for (int i = 0; i < mineLaerere.Count; i++)
        {
            Debug.Log(mineLaerere[i].Navn);
        }
    }
        //// there is a teacher clash if the teacher for the lecture has already been assigned to the same timeslot
        //public bool TeacherClash2(List<SchemaCourse> planned, Laerer teacher, LectureTime time)
        //{
        //    // All the already planned schemacourses, where a teacher has been booked to teach a course
        //    IEnumerable<SchemaCourse> coursesForThisTeacher = planned.Where(sc => sc.Course.LaererObj == teacher);
        //    //a call to the method 'Any' returns true or false
        //    return coursesForThisTeacher.Any(sc => sc.LectureTimes.Contains(time));

        //    //return planned.Where(sc => sc.Course.LaererObj == teacher).Any(sc => sc.LectureTimes.Contains(time));
        //}


        /// <summary>
        /// checks if the teacher for the lecture has already been assigned to the same timeslot somewhere else
        /// </summary>
        /// <param name="planned">a list containing all the already scheduled courses</param>
        /// <param name="teacher">the teacher we are making a check for</param>
        /// <param name="time">the lecturetime we are checking</param>
        /// <returns>true if either a teacher or a hold has been scheduled at the same time and false otherwise</returns>
        public bool TeacherClash(List <SchemaCourse> planned, Laerer teacher, LectureTime time)
        {
            bool result = false;

            foreach (SchemaCourse sc in planned)
            {
                if (sc.Course.LaererObj == teacher)
                {
                    foreach (LectureTime lt in sc.LectureTimes)
                    {
                        if (lt == time)
                        {
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }