Exemple #1
0
        public static void Main()
        {
            Person test1 = new Person("Test1", "Test", 20);
            Trainer test2 = new Trainer("Test2", "Test", 20);
            JuniorTrainer test3 = new JuniorTrainer("Test3", "Test", 20);
            SeniorTrainer test4 = new SeniorTrainer("Test4", "Test", 20);
            GraduateStudent test5 = new GraduateStudent("Test5", "Test", 20, "123", 5.23d);
            DropoutStudent test6 = new DropoutStudent("Test6", "Test", 20, "123", 4.23d, "Low average grade");
            CurrentStudent test7 = new CurrentStudent("Test7", "Test", 20, "123", 5.48d, "OOP");
            OnlineStudent test8 = new OnlineStudent("Test8", "Test", 20, "123", 5.48d, "OOP");
            OnsiteStudent test9 = new OnsiteStudent("Test9", "Test", 20, "123", 3.23d, "OOP", 2);

            test2.CreateCourse("OOP");
            test3.CreateCourse("OOP");
            test4.DeleteCourse("OOP");

            List<Person> persons = new List<Person>() { test1, test2, test3, test4, test5, test6, test7, test8, test9 };
          
            var currentStudents = persons
                            .Where(person => person is CurrentStudent) 
                            .OrderBy(person => ((Student)person).AverageGrade)
                            .Select(person => person);

            foreach (var student in currentStudents)
            {
                Console.WriteLine(student);
            }
        }
Exemple #2
0
        static void Main()
        {
            List <Person> person = new List <Person>();

            List <Trainer> trainer = new List <Trainer>();
            List <Student> student = new List <Student>();

            List <JuniorTrainer> juniorTrainer = new List <JuniorTrainer>();
            List <SeniorTrainer> seniorTrainer = new List <SeniorTrainer>();

            List <GraduateStudent> graduateStudent = new List <GraduateStudent>();
            List <CurrentStudent>  currentStudent  = new List <CurrentStudent>();
            List <DropoutStudent>  dropoutStudent  = new List <DropoutStudent>();

            List <OnsiteStudent> onsiteStudent = new List <OnsiteStudent>();
            List <OnlineStudent> onlineStudent = new List <OnlineStudent>();

            Person Gosho = new Person("Georgi", "Borimechkov", 59);
            //Person Pesho = new Person("Petur", "Petrov", 3); //Here will throw ArgumentOutOfRangeException
            Person Peshka = new Person("Petur", "Petrov", 23);


            person.Add(Gosho);
            person.Add(Peshka);

            OnsiteStudent Tosho = new OnsiteStudent("Tihomir", "Dikov", 44, 333333, 5.33d, "Fundamentals", 40);
            OnsiteStudent Misho = new OnsiteStudent("Mihail", "Dimov", 15, 131313, 5.85d, "C# Basics", 8);

            //OnlineStudent Daniela = new OnlineStudent("Daniela", "Bumbarova", 3, 100003, 3.21d, "Back-end");
            //Here will throw the same ArgumentOutOfRangeException
            OnlineStudent Lilly = new OnlineStudent("Lilly", "Dimitrova", 34, 414344, 4.21d, "Back-end");
            OnlineStudent Bobi  = new OnlineStudent("Borislav", "Bobcho", 24, 132414, 4.94d, "Front-end");


            //Adding them in and sorting the list.
            currentStudent.Add(Tosho);
            currentStudent.Add(Misho);
            currentStudent.Add(Lilly);
            currentStudent.Add(Bobi);

            List <CurrentStudent> currentStudentSorted = currentStudent.OrderBy(p => p.AvarageGrade).ToList();

            foreach (var stud in currentStudentSorted)
            {
                Console.WriteLine(stud);
            }
        }
        static void Main(string[] args)
        {
            //Normal Person
            Person normalGosho = new Person("Gosho", "Batka", 15);

            //Trainer
            Trainer Pesho = new Trainer("Pesho", "Ganev", 34);
            Pesho.CreateCourse("C# Fundamentals");
            Pesho.CreateCourse("");
            Pesho.CreateCourse("Java Basics");
            Pesho.CreateCourse("PHP");
            Trainer.ViewCourses();
            Console.WriteLine(new String('-', 40));

            //Senior Trainer
            SeniorTrainer Nakov = new SeniorTrainer("Svetlin", "Nakov");
            Nakov.CreateCourse("Ninja Programmer");
            SeniorTrainer.ViewCourses();
            Nakov.RemoveCourse("Java Basics");
            Nakov.RemoveCourse("DrunDrun");
            Trainer.ViewCourses();
            Console.WriteLine(new String('-', 40));

            //Junior Trainer
            JuniorTrainer Penka = new JuniorTrainer("Penka");

            //Student
            Student Borcho = new Student("Borcho", 5189154, 5.5, "Penchev", 54);

            //Graduate Student
            GraduateStudent Dimitri = new GraduateStudent("Dimitri", 132623453, 4.3);

            //Current Student
            CurrentStudent Bachi = new CurrentStudent("Bachi", 623454235, 3.4, "Math Algorithms");

            //Droput Student 
            DropoutStudent Ivancho = new DropoutStudent("Ivancho", 412341, 2.0, "I can't learn regex expressions");
            Ivancho.Reapply();
            Console.WriteLine(new String('-', 40));

            //Online Student
            OnlineStudent Qwerty = new OnlineStudent("Qwerty", 273485, 4.5, "PHP");

            //Onsite Student
            OnsiteStudent Gencho = new OnsiteStudent("Gencho", 513451, 6.0, "Java", 84);
            OnsiteStudent Mariika = new OnsiteStudent("Mariika", 45634653, 5.9, "JavaScript", 34, "Pencheva", 45);

            List<Person> people = new List<Person>()
	        {
	            Bachi,
                Gencho,
                Mariika,
                Qwerty,
                Penka,
                Borcho,
                Dimitri, 
                Ivancho,
                normalGosho,
                Nakov
	        };

            people.Where(x => x.GetType().BaseType.Name == "CurrentStudent").OrderByDescending(x => ((Student)x).AveGrade).ToList().ForEach(x => Console.WriteLine(x.Name + " -> " + ((Student)x).AveGrade));

        }