public void Test_AddDefaults()
        {
            StudentCollection sc = new StudentCollection();

            sc.AddDefaults();
            Console.WriteLine(sc.ToString());
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            StudentCollection FirstCollect  = new StudentCollection(); //Liste d'eleve Numero 1
            StudentCollection SecondCollect = new StudentCollection(); //Liste d'eleve Numero 2

            FirstCollect.CollectionName  = "Collection numero 1";      //ChangeToRussian
            SecondCollect.CollectionName = "collection numero 2";      //ChangeToRussian
            StudentCollection[] FirstArray    = { FirstCollect };
            StudentCollection[] SecondArray   = { FirstCollect, SecondCollect };
            Journal             FirstJournal  = new Journal(FirstArray);  //Journal Numero 1
            Journal             SecondJournal = new Journal(SecondArray); //Journal Numero 2

            Console.WriteLine("-------------------------------------------Etape1");
            FirstCollect.AddDefaults();                                                                                                                                                                                                                                                                                                                                                                                                                                        //premiere modification sur une liste
            SecondCollect.AddDefaults();
            Student[] StudentToAdd = { new Student("Developpeur c#", 8977, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)), new Student("Developpeur c++", 8077, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)), new Student("Developpeur c", 18977, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)), new Student("Developpeur Javascript", 89770, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)) }; //ChangeToRussian
            FirstCollect.AddStudent(StudentToAdd);
            FirstCollect.Remove(1);
            FirstCollect.Remove(50);
            SecondCollect[0] = new Student("Developpeur Python", 2145, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5));                         //La reference A ete changer //ChangeToRussian
            SecondCollect.AddStudent(new Student[] { new Student("Developpeur Ruby", 77544, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)) }); //ChangeToRussian
            Console.WriteLine("--------------------------------------------Etape2");                                                                              //ChangeToRussian
            Console.WriteLine(FirstJournal.ToString());
            Console.WriteLine(SecondJournal.ToString());
            Console.WriteLine("-----------------------------------Etape 3");               //ChangeToRussian
            Console.WriteLine("Verifions le resume" + FirstCollect.ToString());            //ChangeToRussian
            Console.WriteLine("Verifions le court Resume" + FirstCollect.ToShortString()); //ChangeToRussian
        }
        public void Test_CollectionName()
        {
            StudentCollection sc = new StudentCollection();

            sc.AddDefaults();
            sc.CollectionName = "Some Collection";
            Assert.AreEqual("Some Collection", sc.CollectionName);
        }
        public void TestStudentCountChanged()
        {
            StudentCollection sc      = new StudentCollection();
            Journal           journal = new Journal();

            sc.StudentsCountChanged += journal.handle_StudentsCountChanged;
            sc.AddDefaults();
            Console.WriteLine(journal.ToString());
        }
        public void TestRemove()
        {
            StudentCollection sc = new StudentCollection();

            // Add 5 default student objects
            sc.AddDefaults();
            Assert.AreEqual(true, sc.Remove(3));
            Console.WriteLine(sc.ToString());
            Assert.AreEqual(false, sc.Remove(4));
        }
        public void TestIndexator()
        {
            StudentCollection sc = new StudentCollection();

            sc.AddDefaults();
            sc[3] = new Student(new Person("Pee-Wee", "Jurker", new DateTime(1985, 12, 3)), Education.Bachelor, 123);
            Console.WriteLine(sc.ToString());
            sc[6] = new Student();
            Student stud = sc[0];

            Assert.AreEqual(new Student(), stud);
            stud = sc[7];
            Assert.AreEqual(null, stud);
        }
Beispiel #7
0
        static void Main()
        {
            var student = new Student
            {
                Birthday = DateTime.Parse("01.03.1994"),
                Exams = new List<Exam>
                {
                    new Exam {DisciplineName = "English", Mark = 6, Date = DateTime.Parse("03.12.2015")},
                    new Exam {DisciplineName = "Math", Mark = 3, Date = DateTime.Parse("03.05.2015")},
                    new Exam {DisciplineName = "Physics", Mark = 7, Date = DateTime.Parse("03.21.2015")},
                    new Exam {DisciplineName = "Biology", Mark = 5, Date = DateTime.Parse("03.17.2015")}
                },
                Education = Education.Bachelor
            };

            Console.WriteLine($"Source student:\n{student}\n");

            Console.WriteLine("Sorted exams by discipline name:\n");
            student.SortExamsByDisciplineName();
            Console.WriteLine(student);
            Console.WriteLine();

            Console.WriteLine("Sorted exams by mark:\n");
            student.SortExamsByMark();
            Console.WriteLine(student);
            Console.WriteLine();

            Console.WriteLine("Sorted exams by date:\n");
            student.SortExamsByDate();
            Console.WriteLine(student);
            Console.WriteLine();

            var students = new StudentCollection<string>(s => s.PersonId.ToString());
            students.AddDefaults(2);

            var student2 = new Student
            {
                Education = Education.Bachelor,
                Exams = new List<Exam>
                {
                    new Exam {DisciplineName = "English", Mark = 4, Date = DateTime.Parse("03.12.2015")},
                    new Exam {DisciplineName = "Math", Mark = 7, Date = DateTime.Parse("03.05.2015")},
                    new Exam {DisciplineName = "Physics", Mark = 9, Date = DateTime.Parse("03.21.2015")},
                    new Exam {DisciplineName = "Biology", Mark = 10, Date = DateTime.Parse("03.17.2015")}
                }
            };

            var student3 = new Student
            {
                Education = Education.Bachelor,
                Exams = new List<Exam>
                {
                    new Exam {DisciplineName = "English", Mark = 7, Date = DateTime.Parse("03.12.2015")},
                    new Exam {DisciplineName = "Math", Mark = 4, Date = DateTime.Parse("03.05.2015")},
                    new Exam {DisciplineName = "Physics", Mark = 8, Date = DateTime.Parse("03.21.2015")},
                    new Exam {DisciplineName = "Biology", Mark = 6, Date = DateTime.Parse("03.17.2015")}
                }
            };

            students.AddStudents(student, student2, student3);
            Console.WriteLine($"StudentCollection<string>:\n{students}");
            Console.WriteLine();
            Console.WriteLine($"StudentCollection<string>(short):\n{students.ToShortString()}");
            Console.WriteLine();

            Console.WriteLine($"Max average mark: {students.MaxAverageMark}\n");

            Console.WriteLine("The list of Bachelors:");
            var bachelors = students.GetWithEducationForm(Education.Bachelor);
            foreach (var bachelor in bachelors)
            {
                Console.WriteLine(bachelor.Value);
            }
            Console.WriteLine();

            Console.WriteLine("Grouping by education:");
            var grouped = students.GroupByEducation;
            foreach (var group in grouped)
            {
                Console.WriteLine($"{group.Key}:");
                foreach (var item in group)
                {
                    Console.WriteLine(item.Value);
                }
                Console.WriteLine();
            }


            var testCollections = new TestCollections<Person, Student>(5, count =>
            {
                var tempStudent = new Student();
                return new KeyValuePair<Person, Student>(tempStudent.Key, tempStudent);
            });
            for (var att = 0; att < TestAttemptsCount; att++)
            {
                Console.WriteLine($"************************ TEST {att} ************************");
                testCollections.PerformSearch(testCollections.Value,
                    tuple => Console.WriteLine($"{tuple.Item1} : {tuple.Item2}"));
                Console.WriteLine();
            }
        }