Beispiel #1
0
        static void Main(string[] args)
        {
            GraduateStudentCollection <string> coll1 = new GraduateStudentCollection <string>(MakeKey);
            GraduateStudentCollection <string> coll2 = new GraduateStudentCollection <string>(MakeKey);
            TeamsJournal journal = new TeamsJournal();

            coll1.Name = "firstCollection";
            coll2.Name = "secondCollection";
            coll1.GraduateStudentsChanged += journal.GraduateStudentsChangedHandler;
            coll2.GraduateStudentsChanged += journal.GraduateStudentsChangedHandler;
            GraduateStudent g1 = new GraduateStudent(new Person("Anna", "Fedorova", new DateTime()), new Person("Anna", "Fedorova", new DateTime()), "pos", "spec", 0, 3);
            GraduateStudent g2 = new GraduateStudent(new Person("Zain", "Cherry", new DateTime()), new Person("Zain", "Cherry", new DateTime()), "pos", "spec", 0, 3);
            GraduateStudent g3 = new GraduateStudent(new Person("Kimberley", "Harmon", new DateTime()), new Person("Kimberley", "Harmon", new DateTime()), "pos", "spec", 0, 3);
            GraduateStudent g4 = new GraduateStudent(new Person("Kairon", "Sharp", new DateTime()), new Person("Kairon", "Sharp", new DateTime()), "pos", "spec", 0, 3);
            GraduateStudent g5 = new GraduateStudent(new Person("Gurveer", "Fulton", new DateTime()), new Person("Gurveer", "Fulton", new DateTime()), "pos", "spec", 0, 3);
            GraduateStudent g6 = new GraduateStudent(new Person("Catrina", "Allen", new DateTime()), new Person("Catrina", "Allen", new DateTime()), "pos", "spec", 0, 3);

            coll1.AddGraduateStudent(g1, g2, g3);
            coll2.AddGraduateStudent(g1, g2, g3);
            g1.Speciality = "Specialty is changed";
            g4.Form       = FormOfStudy.Distance;
            coll1.Remove(g2);
            g2.Form = FormOfStudy.PartTime;
            GraduateStudent g7 = new GraduateStudent(new Person(), new Person(), "pos", "spec", 0, 3);

            coll2.Replace(g3, g7);
            g3.Speciality = "Specialty is changed";
            Console.WriteLine(journal);

            Console.WriteLine($"Max learning year:\n{coll1.MaxLearningYear}");

            Console.WriteLine($"Tution form full time:\n");
            var SelectedForm = coll1.TuitionForm(0);

            if (SelectedForm.Any())
            {
                foreach (var s in SelectedForm)
                {
                    Console.WriteLine(s.Value);
                }
            }

            Console.WriteLine($"Grouped by form of study:\n");
            var formOfStudyGroups = coll1.Grouped;

            if (formOfStudyGroups.Any())
            {
                foreach (var f in formOfStudyGroups)
                {
                    Console.WriteLine($"Form of Study: {f.Key}");
                    foreach (var item in f)
                    {
                        if (item.Value != null)
                        {
                            Console.WriteLine(item.Value);
                        }
                    }
                }
            }
        }
Beispiel #2
0
 public void AddDefaults(int size)
 {
     for (int i = 0; i < size; i++)
     {
         GraduateStudent grd = new GraduateStudent();
         grd.LastName = grd.LastName + i;
         TKey k = theKey(grd);
         GraduateStudentsDictionaryCollection.Add(k, grd);
     }
 }
Beispiel #3
0
 public bool Remove(GraduateStudent rt)
 {
     if (GraduateStudentsDictionaryCollection.ContainsValue(rt))
     {
         foreach (KeyValuePair <TKey, GraduateStudent> kvp in GraduateStudentsDictionaryCollection)
         {
             if (kvp.Value == rt)
             {
                 kvp.Value.PropertyChanged -= GraduateStudentPropertyChanged;
                 GraduateStudentsDictionaryCollection.Remove(kvp.Key);
                 GraduateStudentsChanged?.Invoke(kvp.Value, new GraduateStudentsChangedEventArgs <TKey>(Name, Revision.Remove, "", kvp.Value.LearningYear));
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #4
0
        public override object DeepCopy()
        {
            GraduateStudent g = (GraduateStudent)this.MemberwiseClone();

            g.PersonProperty    = (Person)this.PersonProperty.DeepCopy();
            g.EmployeePosition  = new string(EmployeePosition); //String.Copy(EmployeePosition);
            g.Supervisor        = (Person)this.Supervisor.DeepCopy();
            g.Speciality        = new string(Speciality);       //String.Copy(Speciality);
            g.ArticlesPublished = new List <Article>();
            for (int i = 0; i < ArticlesPublished.Count; i++)
            {
                g.ArticlesPublished.Add((Article)this.ArticlesPublished[i].DeepCopy());
            }
            g.NotesMade = new List <Notes>();
            foreach (Notes n in this.NotesMade)
            {
                g.NotesMade.Add((Notes)n.DeepCopy());
            }
            return(g);
        }
Beispiel #5
0
 static string MakeKey(GraduateStudent g)
 {
     return(g.ToString());
 }