public void Update()
        {
            /*Forgotters.Clear();
             * var disciplines = AchievementState.Instance().Disciplines;
             * if (disciplines != null)
             *  foreach (var discipline in disciplines.Where(x =>
             *      x.Achievements.Count != x.Groups.Count))
             *  {
             *      Forgotters.Add(discipline.TeacherCurator);
             *  }
             */
            Forgotters.Clear();
            var disciplines = AchievementState.Instance().Disciplines;

            foreach (var discipline in disciplines /*.Where(x => x == x.Achievements.Where(y => y.Marks.Count == 0))*/)
            {
                if (discipline.Achievements.Where(x => x.Week == StudyWeek.Instance().Num).FirstOrDefault <Achievement>()?.Marks.Count == 0)
                {
                    if (Forgotters.ContainsKey(discipline.CathedraCurator.Name))
                    {
                        Forgotters[discipline.CathedraCurator.Name].Add(discipline.TeacherCurator);
                    }
                    else
                    {
                        Forgotters[discipline.CathedraCurator.Name] = new List <Teacher>();
                        Forgotters[discipline.CathedraCurator.Name].Add(discipline.TeacherCurator);
                    }
                }
            }

            NotifyObservers();
        }
        public string Info()
        {
            StringBuilder str = new StringBuilder();

            for (int i = 1; i <= StudyWeek.Instance().Num; i++)
            {
                str.Append($"{Info(i)}\n");
            }

            return(str.ToString());
        }
        /// <summary>
        /// update
        /// </summary>
        /// <param name="o">preferably as study week</param>
        public void Update()
        {
            var disciplines = AchievementState.Instance().Disciplines.Where(x => x.TeacherCurator.Fio.Equals(this.Fio));

            foreach (var discipline in disciplines)
            {
                AchievementState.Instance().AddRecord(
                    discipline,
                    new Achievement().CreateAchievements(
                        StudyWeek.Instance().Num,
                        discipline.Groups
                        )
                    );
            }
        }
 public void Update()
 {
     if (Decanat.Instance().Forgotters.ContainsKey(this.Name))
     {
         foreach (var teacher in Decanat.Instance().Forgotters[this.Name])
         {
             if (BadTeachers.ContainsKey(StudyWeek.Instance().Num))
             {
                 BadTeachers[StudyWeek.Instance().Num].Add(teacher);
             }
             else
             {
                 BadTeachers.Add(StudyWeek.Instance().Num, new List <Teacher>());
                 BadTeachers[StudyWeek.Instance().Num].Add(teacher);
             }
         }
     }
     else
     {
         BadTeachers.Add(StudyWeek.Instance().Num, new List <Teacher>());
     }
 }
Exemple #5
0
 public static StudyWeek Instance(int weeks = 18)
 {
     return(_instance ?? (_instance = new StudyWeek(weeks)));
 }
        static void Main(string[] args)
        {
            List <Teacher> teachers = new List <Teacher>()
            {
                new Teacher("Teach1"),
                new Teacher("Teach2"),
                new Teacher("Teach3")
            };

            foreach (var teacher in teachers)
            {
                StudyWeek.Instance().AddObserver(teacher);
            }

            List <Cathedra> cathedras = new List <Cathedra>()
            {
                new Cathedra("Cth1", new List <Teacher>()
                {
                    teachers[0], teachers[1]
                }),
                new Cathedra("Cth2", new List <Teacher>()
                {
                    teachers[1], teachers[2]
                })
            };

            AchievementState achievementsStats = AchievementState.Instance();

            List <Discipline> disciplines = new List <Discipline>()
            {
                new Discipline("d1", cathedras[0], teachers[0])
                {
                    Groups = new List <string>()
                    {
                        "G1", "G2"
                    }
                },
                new Discipline("d2", cathedras[0], teachers[1])
                {
                    Groups = new List <string>()
                    {
                        "G3", "G2"
                    }
                },
                new Discipline("d3", cathedras[1], teachers[1])
                {
                    Groups = new List <string>()
                    {
                        "G4", "G3"
                    }
                },
                new Discipline("d4", cathedras[1], teachers[2])
                {
                    Groups = new List <string>()
                    {
                        "G1", "G4"
                    }
                }
            };

            achievementsStats.Disciplines.AddRange(disciplines);

            //achievementsStats.AddObserver(Decanat.Instance());
            StudyWeek.Instance().AddObserver(Decanat.Instance());
            foreach (var cathedra in cathedras)
            {
                Decanat.Instance().AddObserver(cathedra);
            }


            StudyWeek.Instance().NewWeek();
            while (!StudyWeek.Instance().IsSession)
            {
                //show info about current week achievements
                Console.WriteLine(achievementsStats.Info(StudyWeek.Instance().Num));
                //show info message for current week for all cathedras
                Console.WriteLine($"Bad teaqchers on {StudyWeek.Instance().Num}th week:");
                foreach (var cathedra in cathedras)
                {
                    Console.WriteLine(cathedra.MesInfo(StudyWeek.Instance().Num));
                }
                Console.WriteLine();

                //new week begin
                StudyWeek.Instance().NewWeek();
            }

            Console.ReadKey();
        }