public static double Average(this StudentCollection <string> dict) { double av = 0; int counter = 0; foreach (var s in dict.list.Values.ToList()) { av += s.GPA; counter++; } return(av / counter); }
static void Main(string[] args) { string stars = "\n******************************************************************\n"; StudentCollection <string> list1 = new StudentCollection <string>("Collection1"); StudentCollection <string> list2 = new StudentCollection <string>("Collection2"); Journal <string> j1 = new Journal <string>(); list1.StudentChanged += j1.StudentChanged; list2.StudentChanged += j1.StudentChanged; Student st1 = new Student(new Person("Joe", "Claire", new DateTime(2002, 12, 14)), Education.Вachelor, 3); list1.AddStudents("s1", st1); list2.AddStudents("s2", new Student(new Person("Jude", "Harley", new DateTime(2002, 06, 13)), Education.Вachelor, 4)); list1.AddDefaults("s3"); list2.AddDefaults("s4"); Student st2 = new Student(new Person("Jane", "Crocker", new DateTime(1996, 4, 13)), Education.Вachelor, 4); bool newflag = list1.Remove(st1); bool newflag1 = list2.Remove(st2); // s1 s4; st1.Gr = 6; list2["s2"].Educat = Education.Specialist; list1["s3"].Gr = 7; Console.WriteLine(stars); Console.WriteLine("Journal1:\n"); Console.WriteLine(j1.ToString()); /*Console.WriteLine(stars); * Console.WriteLine(list2.ToString());*/ // Console.WriteLine(list2[3].ToShortString()); Student s1 = new Student(new Person("John", "Egbert", new DateTime(1995, 04, 13)), Education.Specialist, 2); Student s2 = new Student(new Person("Dave", "Strider", new DateTime(1995, 12, 03)), Education.Specialist, 5); Student s3 = new Student(new Person("Rose", "Lalond", new DateTime(1995, 12, 4)), Education.SecondEducation, 5); Student s4 = new Student(new Person("Jade", "Harley", new DateTime(1995, 12, 1)), Education.Вachelor, 4); Exam[] exams0 = { new Exam("Chemistry", 100, new DateTime(2007, 05, 14)), new Exam("Math", 89, new DateTime(2007, 05, 16)), new Exam("Literarure", 45, new DateTime(2007, 06, 01)), new Exam("Driving", 55, new DateTime(2010, 12, 10)),//72.25 }; Exam[] exams1 = { new Exam("Chemistry", 75, new DateTime(2007, 05, 14)), new Exam("Math", 64, new DateTime(2007, 05, 16)), new Exam("Literarure", 22, new DateTime(2007, 06, 01)), new Exam("Driving", 95, new DateTime(2010, 12, 10)),//64 }; Exam[] exams2 = { new Exam("Chemistry", 85, new DateTime(2007, 05, 14)), new Exam("Math", 55, new DateTime(2007, 05, 16)), new Exam("Literarure", 45, new DateTime(2007, 06, 01)), new Exam("Driving", 95, new DateTime(2010, 12, 10)),//70 }; Exam[] exams3 = { new Exam("Chemistry", 93, new DateTime(2007, 05, 14)), new Exam("Math", 93, new DateTime(2007, 05, 16)), new Exam("Literarure", 95, new DateTime(2007, 06, 01)), new Exam("Driving", 94, new DateTime(2010, 12, 10)),//93.75 }; s1.AddExams(exams0); s2.AddExams(exams1); s3.AddExams(exams2); s4.AddExams(exams3); list1.AddStudents("st1", s1); list1.AddStudents("st2", s2); list1.AddStudents("st3", s3); list1.AddStudents("st4", s4); Console.WriteLine(stars); Console.WriteLine(list1.ToString()); Console.WriteLine("Average GPA: "); Console.WriteLine(list1.Average());//60 Console.ReadKey(); }