Ejemplo n.º 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);
            }
        }
Ejemplo n.º 2
0
        internal static void Main()
        {
            // test trainer methods
            var juniorTrainer = new JuniorTrainer("Elena", "Bojilova", 24);
            var seniorTrainer = new SeniorTrainer("Filip", "Kolev", 25);

            juniorTrainer.CreateCourse("OOP");
            seniorTrainer.CreateCourse("HQC");
            seniorTrainer.DeleteCourse("OOP");
            Console.WriteLine();

            // test Reapply() method
            var applicant = new DropoutStudent("Prekusnal", "Student", 21, 1222, 3.03, "Murzi me");

            applicant.Reapply();
            Console.WriteLine();

            // Create a list of objects from each class
            var people = new List <Person>
            {
                new JuniorTrainer("Ivan", "Ivanov Jr.", 19),
                new SeniorTrainer("Ivan", "Ivanov Sr.", 45),
                new DropoutStudent("Misho", "Mihaylov", 25, 1234, 3.5, "Mrazim da mislim"),
                new GraduateStudent("Viktor", "Kazakov", 31, 1235, 5.25),
                new OnlineStudent("Elena", "Bojilova", 23, 1236, 5.75, "OOP"),
                new OnlineStudent("Pavleta", "Taseva", 21, 1237, 5.5, "OOP"),
                new OnsiteStudent("Svetlin", "Nakov", 34, 1238, 6, "OOP", 15),
            };

            // Extract only the Current Students, sort them by average grade
            var sortedCurrentStudents =
                people.Where(a => a is CurrentStudent)
                .Cast <CurrentStudent>()
                .OrderBy(a => a.AverageGrade);

            // printing
            Console.WriteLine("List of current students (sorted by average grade):");
            Console.WriteLine();

            foreach (var student in sortedCurrentStudents)
            {
                Console.WriteLine(student);
            }
        }
Ejemplo n.º 3
0
        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));

        }