示例#1
0
        internal static void Main()
        {
            //testing SoftUni's learning system
            //testing students
            CurrentStudent crntStudent = new CurrentStudent("Ivan", "Ivanich", 25, 12478, 5.32, "OOP");
            Console.WriteLine(crntStudent);
            Console.WriteLine();
            DropoutStudent drpStudent = new DropoutStudent("Prekusnal", "Student", 21, 12202, 3.03, "Murzi me");
            drpStudent.ReApply();
            Console.WriteLine();
            GraduatedStudent gradStudent = new GraduatedStudent("Evgeni", "Minchev", 35, 22471, 5.92);
            Console.WriteLine(gradStudent);
            Console.WriteLine();

            OnlineStudent onlnStd = new OnlineStudent("Mircho", "Mirchev", 27, 65234, 5.47, "OOP");
            Console.WriteLine(onlnStd);
            Console.WriteLine();
            OnsiteStudent onstStd = new OnsiteStudent("Stef", "Andres", 23, 52416, 4.99, 4, "HQC");
            Console.WriteLine(onstStd);
            Console.WriteLine();

            //testing trainers
            JuniorTrainer jun = new JuniorTrainer("Fil", "Kolev", 32);
            Console.WriteLine(jun);
            jun.CreateCourse("OOP");
            jun.CreateCourse("HQC");
            Console.WriteLine();

            SeniorTrainer sen = new SeniorTrainer("Svetlin", "Nakov", 41);
            Console.WriteLine(sen);
            sen.CreateCourse("Data bases");
            sen.CreateCourse("ASP.Net MCV basics");
            sen.DeleteCourse("OOP");
        }
示例#2
0
        static void Main(string[] args)
        {
            JuniorTrainer jt = new JuniorTrainer("Azis", "Pedro", 55);
            jt.CreateCourse("C#");
            SeniorTrainer st = new SeniorTrainer("Kalin","kolev",22);
            st.RemoveCourse("C#");
            List<Person> persons = new List<Person>();
            DropoutStudent ds = new DropoutStudent("Pesho", "Ivanov", 25);
            ds.DropoutReason = "sucks";
            ds.Reapply();
            persons.Add(jt);
            persons.Add(st);
            persons.Add(ds);
            persons.Add(new GraduateStudent("Asen","Marinov",53){AvgGrade = 5.5d});

            persons.Add(new OnlineStudent("Loki1","Thor",25,2554,5.4,"OOP"));
            persons.Add(new OnsiteStudent("Asen","Lazarov",25){ Age = 25, CurrentCourse = "C#" , AvgGrade = 4.5d});
            persons.Add(new CurrentStudent() { Age = 23, CurrentCourse = "C#", FirstName = "Ce", LastName = "Bq",AvgGrade = 6.0d});
            persons.Add(new CurrentStudent() { Age = 22, CurrentCourse = "C#", FirstName = "Loki3", LastName = "Thor",AvgGrade = 5.4d});

            var personz = persons.Select(s => s).OfType<CurrentStudent>().OrderBy(s => s.AvgGrade);

            foreach (var person in personz)
            {
                Console.WriteLine(person);
                Console.WriteLine(person.AvgGrade);
                Console.WriteLine();
            }
        }
        static void Main()
        {
            Trainer nikbank = new JuniorTrainer("Nikolay", "Bankin", 20);
            Trainer vGeorg  = new SeniorTrainer("Vlado", "Geogiev", 25);
            Trainer nakov   = new SeniorTrainer("Svetlin", "Nakov", 32);
            Trainer aRus    = new JuniorTrainer("Atanas", "Rusenov", 18);

            Student toi    = new GraduateStudent("Zavyrshil", "Student", 21, "80002341", (float)5.46);
            Student blagoi = new GraduateStudent("Blago", "Peshev", 25, "80002145", (float)5.22);
            Student misho  = new GraduateStudent("Misho", "Mishev", 12, "80004587", (float)5.96);

            Student pesho = new DropoutStudent("Pesho", "Peshev", 23, "40001234", (float)2.33, "low result");
            Student katya = new DropoutStudent("Katya", "Ivanova", 72, "40005678", (float)4.33, "family reasons");

            CurrentStudent valyo   = new OnlineStudent("Valentin", "Petrov", 11, "50006541", (float)3.45, "Java Basics");
            CurrentStudent geca    = new OnlineStudent("Georgi", "Petrov", 34, "50002389", (float)4.45, "JavaScript Basics");
            CurrentStudent batkata = new OnsiteStudent("Botyo", "Botev", 36, "50009841", (float)5.85, "C# Basics", 8);

            List <Person> persons = new List <Person>()
            {
                nikbank, vGeorg, nakov, aRus, toi, blagoi, misho,
                pesho, katya, valyo, geca, batkata
            };


            persons.Where(p => p is CurrentStudent).OrderBy(p => ((Student)p).AverageGrade).ToList().ForEach(p => Console.WriteLine(p.ToString()));
        }
示例#4
0
    static void Main()
    {
        Trainer       regularTrainer = new Trainer("Gogo", "Strogiya", 60);
        JuniorTrainer juniorTrainer  = new JuniorTrainer("Asistent", "Pomagachev", 24);
        SeniorTrainer seniorTrainer  = new SeniorTrainer("Golemec", "Shisharkov", 42);

        regularTrainer.CreateCourse("OOP");
        juniorTrainer.CreateCourse("QPC");
        seniorTrainer.CreateCourse("ABC");
        seniorTrainer.DeleteCourse("DEF");
        Console.WriteLine();

        DropoutStudent applicant = new DropoutStudent("Otpadnal", "Student", 21, 1222, 3.03, "Nyama bira!!!");

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

        var people = new List <Person>
        {
            new Person("Georgi", "Georgiev", 20),
            new Trainer("Ivan", "Ivanov", 28),
            new JuniorTrainer("Ivan", "Ivanov Jr.", 19),
            new SeniorTrainer("Ivan", "Ivanov Sr.", 35),
            new Student("Pesho", "Peshev", 22, 1234, 5.75),
            new DropoutStudent("Misho", "Mihaylov", 25, 1234, 3.5, "Too few women on campus."),
            new GraduateStudent("Golemets", "Golemiya", 31, 1234, 5.25),
            new CurrentStudent("Stamat", "Botusharov", 23, 1234, 3.25, "OOP"),
            new OnlineStudent("Myrzeliv", "Myrzelivets", 21, 1234, 2.5, "OOP"),
            new OnsiteStudent("Svetlin", "Nakov", 34, 1234, 6, "OOP", 15),
            new CurrentStudent("Irokentij", "Portokalov", 43, 1234, 4.25, "QPC"),
            new OnlineStudent("Onufrij", "Popryckov", 63, 1234, 5.15, "QPC"),
            new OnsiteStudent("Maria", "Ivanova", 19, 1234, 5.86, "QPC", 12)
        };


        //people.Add(new Person("", "Georgiev", 20));
        //people.Add(new Person("Georgi", " ", 10));
        //people.Add(new Person("Georgi", "Georgiev", -2));
        //people.Add(new Person("Georgi", "Georgiev", 101));
        //people.Add(new Student("Pesho", "Peshev", 22, 11, 2.5));
        //people.Add(new Student("Pesho", "Peshev", 22, 1202022, 2.5));
        //people.Add(new Student("Pesho", "Peshev", 22, 1234, 1.9));
        //people.Add(new Student("Pesho", "Peshev", 22, 1234, 7.5));
        //people.Add(new DropoutStudent("Misho", "Mihaylov", 25, 1234, 3.5, ""));
        //people.Add(new CurrentStudent("Stamat", "Botusharov", 23, 1234, 3.25, " "));

        List <CurrentStudent> currentStudents = people.Where(a => a is CurrentStudent).ToList().Cast <CurrentStudent>().ToList();
        var sortedCurrentStudents             = currentStudents.OrderBy(a => a.AverageGrade);

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

        foreach (var student in sortedCurrentStudents)
        {
            Console.WriteLine(student);
        }
    }
示例#5
0
    static void Main()
    {
        Trainer regularTrainer = new Trainer("Gogo", "Strogiya", 60);
        JuniorTrainer juniorTrainer = new JuniorTrainer("Asistent", "Pomagachev", 24);
        SeniorTrainer seniorTrainer = new SeniorTrainer("Golemec", "Shisharkov", 42);
        regularTrainer.CreateCourse("OOP");
        juniorTrainer.CreateCourse("QPC");
        seniorTrainer.CreateCourse("ABC");
        seniorTrainer.DeleteCourse("DEF");
        Console.WriteLine();

        DropoutStudent applicant = new DropoutStudent("Otpadnal", "Student", 21, 1222, 3.03, "Nyama bira!!!");
        applicant.Reapply();
        Console.WriteLine();

        var people = new List<Person>
        {
            new Person("Georgi", "Georgiev", 20),
            new Trainer("Ivan", "Ivanov", 28),
            new JuniorTrainer("Ivan", "Ivanov Jr.", 19),
            new SeniorTrainer("Ivan", "Ivanov Sr.", 35),
            new Student("Pesho", "Peshev", 22, 1234, 5.75),
            new DropoutStudent("Misho", "Mihaylov", 25, 1234, 3.5, "Too few women on campus."),
            new GraduateStudent("Golemets", "Golemiya", 31, 1234, 5.25),
            new CurrentStudent("Stamat", "Botusharov", 23, 1234, 3.25, "OOP"),
            new OnlineStudent("Myrzeliv", "Myrzelivets", 21, 1234, 2.5, "OOP"),
            new OnsiteStudent("Svetlin", "Nakov", 34, 1234, 6, "OOP", 15),
            new CurrentStudent("Irokentij", "Portokalov", 43, 1234, 4.25, "QPC"),
            new OnlineStudent("Onufrij", "Popryckov", 63, 1234, 5.15, "QPC"),
            new OnsiteStudent("Maria", "Ivanova", 19, 1234, 5.86, "QPC", 12)
        };


        //people.Add(new Person("", "Georgiev", 20));
        //people.Add(new Person("Georgi", " ", 10));
        //people.Add(new Person("Georgi", "Georgiev", -2));
        //people.Add(new Person("Georgi", "Georgiev", 101));
        //people.Add(new Student("Pesho", "Peshev", 22, 11, 2.5));
        //people.Add(new Student("Pesho", "Peshev", 22, 1202022, 2.5));
        //people.Add(new Student("Pesho", "Peshev", 22, 1234, 1.9));
        //people.Add(new Student("Pesho", "Peshev", 22, 1234, 7.5));
        //people.Add(new DropoutStudent("Misho", "Mihaylov", 25, 1234, 3.5, ""));
        //people.Add(new CurrentStudent("Stamat", "Botusharov", 23, 1234, 3.25, " "));

        List<CurrentStudent> currentStudents = people.Where(a => a is CurrentStudent).ToList().Cast<CurrentStudent>().ToList();
        var sortedCurrentStudents = currentStudents.OrderBy(a => a.AverageGrade);

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

        foreach (var student in sortedCurrentStudents)
        {
            Console.WriteLine(student);
        }
    }
示例#6
0
    public static void Main()
    {
        JuniorTrainer   juniorTrainer1   = new JuniorTrainer("Pesho", "Peshov", 24);
        JuniorTrainer   juniorTrainer2   = new JuniorTrainer("GonlineStudentho", "GonlineStudentov", 27);
        JuniorTrainer   juniorTrainer3   = new JuniorTrainer("Vladko", "Vladov", 19);
        SeniorTrainer   seniorTrainer1   = new SeniorTrainer("Petko", "Petkov", 33);
        SeniorTrainer   seniorTrainer2   = new SeniorTrainer("Stefan", "Stefanov", 38);
        SeniorTrainer   seniorTrainer3   = new SeniorTrainer("Martin", "Martinov", 29);
        GraduateStudent graduateStudent1 = new GraduateStudent("Ivan", "Novakov", 35, 30020925, 4.45M);
        GraduateStudent graduateStudent2 = new GraduateStudent("RadonlineStudentlav", "Simeonov", 28, 30058925, 5.80M);
        GraduateStudent graduateStudent3 = new GraduateStudent("Teodor", "Stoychev", 33, 300521345, 3.00M);
        DropoutStudent  dropoutStudent1  = new DropoutStudent("Nakovalnq", "Nakovalnev", 35, 30020925, 4.45M, "...");
        DropoutStudent  dropoutStudent2  = new DropoutStudent("Mmmm", "IdropOut", 28, 30058925, 5.80M, "I dropoutStudentn't care zzzZZZzzz...");
        DropoutStudent  dropoutStudent3  = new DropoutStudent("Arnold", "Ill' be back", 33, 300521345, 3.00M, "Terminated!!!");
        OnlineStudent   onlineStudent1   = new OnlineStudent("Emil", "Stefanov", 48, 40018512, 3.33M, "OOP");
        OnlineStudent   onlineStudent2   = new OnlineStudent("Martin", "Todorov", 22, 40065415, 5.45M, "OOP");
        OnlineStudent   onlineStudent3   = new OnlineStudent("Valeri", "Zahariev", 18, 40018525, 4.89M, "OOP");
        OnsiteStudent   onsiteStudent1   = new OnsiteStudent("Natalya", "Alexandrova", 31, 40089564, 4.00M, "OOP", 5);
        OnsiteStudent   onsiteStudent2   = new OnsiteStudent("Adriyana", "Alexandrova", 25, 40012188, 5.25M, "OOP", 5);
        OnsiteStudent   onsiteStudent3   = new OnsiteStudent("Peter", "Simeonov", 30, 40035698, 3.80M, "OOP", 3);

        juniorTrainer1.CreateCourse("Drink brave!");
        seniorTrainer1.CreateCourse("I'm alive!");
        seniorTrainer2.DeleteCourse("Drink brave!");
        dropoutStudent3.Reapply();

        List <Person> softUniPersons = new List <Person>
        {
            juniorTrainer1,
            juniorTrainer2,
            juniorTrainer3,
            seniorTrainer1,
            seniorTrainer2,
            seniorTrainer3,
            graduateStudent1,
            graduateStudent2,
            graduateStudent3,
            dropoutStudent1,
            dropoutStudent2,
            dropoutStudent3,
            onsiteStudent1,
            onsiteStudent2,
            onsiteStudent3,
            onlineStudent1,
            onlineStudent2,
            onlineStudent3
        };

        SULS testSoftUni = new SULS(softUniPersons);

        testSoftUni.ExtractCurrentStudents();
    }
        static void Main()
        {
            var nikbank = new JuniorTrainer("Nikolay", "Bankin", "8080808080");
            var vKaranf = new SeniorTrainer("Vlado", "Karnfilov", "7070807070");
            Console.WriteLine(nikbank);
            Console.WriteLine(vKaranf);

            nikbank.CreateCourse("OOP");
            vKaranf.CreateCourse("C# Part:2");
            vKaranf.DeleteCourse("C# Part:2");
            Console.WriteLine(new string('*', Console.WindowWidth));

            var student1 = new GradulateStudent("Gosho", "Loshov", "1234567890", 34, 5.60);
            var student2 = new GradulateStudent("Pesho", "Poshov", "1234567890", 12, 3.60);
            var student3 = new GradulateStudent("Mari", "Markova", "1234567890", 1, 4.20);

            var student13 = new DropoutStudent("Niki", "Nikov", "1234567890", 4, 2.00, "low result");
            var student14 = new DropoutStudent("Mari", "Markova", "1234567890", 1, 4.20, "family reason");

            var student11 = new OnlineStudent("Mitko", "Mitkov", "1234567890", 2, 2.60);
            var student21 = new OnsiteStudent("Goro", "Gororv", "1234567890", 2, 5.66);
            student21.Visits = 23;
            var persons = new HashSet<Person>()
            {
                nikbank,
                vKaranf,
                student1,
                student1,
                student11,
                student13,
                student14,
                student2,
                student3,
                student21
            };

            student11.CurrentCourses.Add("C# Part 1");

            var selectedStudents = from person in persons
                                   where person is CurrentStudent
                                   orderby ((Student)person).AverageGrade descending
                                   select person;

            foreach (var student in selectedStudents)
            {
                Console.WriteLine(student);
            }
        }
示例#8
0
 static void Main()
 {
     List<object> list = new List<object>();
     Person stamat = new Person("Stamat", "Stamtov", 18);
     Trainer vladi = new Trainer("Vladi", "Vargala", 24);
     SeniorTrainer nakov = new SeniorTrainer("Svetin", "Nakov", 22);
     JuniorTrainer niki = new JuniorTrainer("Nikolay", "Bankin", 18);
     niki.CreateCourse("Tvardost na betona");
     nakov.DeleteCourse("Tvardost na betona");
     Student mimi = new Student("Mariya", "Ilieva", 25, 1345, 4.60);
     DropoutStudent vasko = new DropoutStudent("Vasko", "Keca", 17, 300, 5, "Music");
     vasko.Reapply();
     GraduateStudent nobody = new GraduateStudent("Misho", "Birata", 40, 20, 3.40);
     OnlineStudent uncleTony = new OnlineStudent("Uncle", "Antony", 25, 7, 5, "OOP");
     CurrentStudent me = new CurrentStudent("Gosho", "Lyaskov", 28, 1, 5.4, "OOP");
     CurrentStudent you = new CurrentStudent("Pesho", "Peshev", 28, 2, 5.1, "OOP");
     CurrentStudent somebody = new CurrentStudent("Uncnown", "Person", 14, 190, 6, "OOP");
     AddtoList(list, stamat, vladi, nakov, niki, mimi, vasko, nobody, uncleTony, me, you, somebody);
     list.Where(x => x is CurrentStudent).OrderByDescending(x => ((Student)x).StudentAverageGrade).ToList().ForEach(x => Console.WriteLine(x.ToString()));
 }
示例#9
0
    static void Main(string[] args)
    {
        var juniorTrainer = new JuniorTrainer("Atanas", "Rusenov", 19);
        var seniorTrainer = new SeniorTrainer("Svetlin", "Nakov", 32);
        juniorTrainer.CreateCourse("Teamwork and personal skills");
        seniorTrainer.CreateCourse("Advanced C#");
        seniorTrainer.DeleteCourse("OOP");
        WriteLine();

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

        // Create a list of objects from each class
        var people = new List<Person>
            {
                new JuniorTrainer("Geogri", "Paskalev Jr.", 19),
                new SeniorTrainer("Ivan", "Ivanov Sr.", 45),
                new DropoutStudent("Misho", "Mihaylov", 25, 1234, 3.5f, "Mrazim da mislim"),
                new GraduateStudent("Viktor", "Kazakov", 31, 1235, 5.25f),
                new OnlineStudent("Elena", "Trendafilova", 23, 1236, 5.75f, "OOP"),
                new OnlineStudent("Pavleta", "Taseva", 21, 1237, 5.5f, "OOP"),
                new OnsiteStudent("Svetlin", "Nakov", 34, 1238, 6, "OOP", 15),
            };
        
        var sortedCurrentStudents =
            people.Where(a => a is CurrentStudent)
                .Cast<CurrentStudent>()
                .OrderBy(a => a.Grade);
        
        WriteLine("List of current students (sorted by average grade):");
        WriteLine();

        foreach (var student in sortedCurrentStudents)
        {
            WriteLine(student);
        }
    }
示例#10
0
        static void Main()
        {
            var nasko = new Trainer("Atanas", "Rusenov", 21);
            var fill = new JuniorTrainer("Filip", "Kolev", 28);
            var nakov = new SeniorTrainer("Svetlin", "Nakov", 60);

            var mark = new GraduateStudent("Марк", "Зукърбъргов", 38, 120511, 6.00);
            var mitio = new DropoutStudent("Митьо", "Крика", 40, 343535, 2.30, "Много големи ръки");
            var djordjano = new CurrentStudent("Djordjano", "Djordjankata", 25, 0888155,"Introducing to singing");
            var baiVulcho = new OnlineStudent("Бай", "Вълчо", 73, 4444, 5.60,"OOP");
            var lelqVanche = new OnsiteStudent("Леля", "Ванче", 57, 12034, 4.89, "Аdvanced C#", 20);

            nakov.DeleteCourse("PHP");
            fill.CreateCourse("Advanced C#");
            nasko.CreateCourse("Kopane");
            nakov.DeleteCourse("Kopane"); // Nasko, what are you doing?!?
            Console.WriteLine();

            var persons = new List<Person>()
            {
                nasko,
                fill,
                nakov,
                mark,
                mitio,
                djordjano,
                baiVulcho,
                lelqVanche
            };

            var currentStudents = persons.Where(student => student is CurrentStudent)
                .OrderBy(student => ((Student)student).AverageGrade)
                .Select(student => student);

            foreach (var currentStudent in currentStudents)
            {
                Console.WriteLine(currentStudent);
            }
        }
示例#11
0
        static void Main()
        {
            var nasko = new Trainer("Atanas", "Rusenov", 21);
            var fill  = new JuniorTrainer("Filip", "Kolev", 28);
            var nakov = new SeniorTrainer("Svetlin", "Nakov", 60);

            var mark       = new GraduateStudent("Марк", "Зукърбъргов", 38, 120511, 6.00);
            var mitio      = new DropoutStudent("Митьо", "Крика", 40, 343535, 2.30, "Много големи ръки");
            var djordjano  = new CurrentStudent("Djordjano", "Djordjankata", 25, 0888155, "Introducing to singing");
            var baiVulcho  = new OnlineStudent("Бай", "Вълчо", 73, 4444, 5.60, "OOP");
            var lelqVanche = new OnsiteStudent("Леля", "Ванче", 57, 12034, 4.89, "Аdvanced C#", 20);

            nakov.DeleteCourse("PHP");
            fill.CreateCourse("Advanced C#");
            nasko.CreateCourse("Kopane");
            nakov.DeleteCourse("Kopane"); // Nasko, what are you doing?!?
            Console.WriteLine();

            var persons = new List <Person>()
            {
                nasko,
                fill,
                nakov,
                mark,
                mitio,
                djordjano,
                baiVulcho,
                lelqVanche
            };

            var currentStudents = persons.Where(student => student is CurrentStudent)
                                  .OrderBy(student => ((Student)student).AverageGrade)
                                  .Select(student => student);

            foreach (var currentStudent in currentStudents)
            {
                Console.WriteLine(currentStudent);
            }
        }
示例#12
0
    static void Main()
    {
        List <Person> softUniPeople  = new List <Person>();
        string        checker        = null;
        uint          studentNumber  = 0u;
        float         averageGrade   = 0f;
        string        currentCourse  = null;
        uint          numberOfVisits = 0u;
        string        dropoutReason  = null;

        do
        {
            Person temp;
            Console.WriteLine("Please choose a type of object:");
            Console.WriteLine("1 - Person");
            Console.WriteLine("2 - Trainer");
            Console.WriteLine("3 - Junior Trainer");
            Console.WriteLine("4 - Senior Trainer");
            Console.WriteLine("5 - Student");
            Console.WriteLine("6 - GraduateStudent");
            Console.WriteLine("7 - CurrentStudent");
            Console.WriteLine("8 - Online Student");
            Console.WriteLine("9 - Onsite Student");
            Console.WriteLine("10 - Dropout Student");
            byte typeOfObject = byte.Parse(Console.ReadLine());
            Console.WriteLine("Please enter a first name:");
            string firstName = Console.ReadLine();
            Console.WriteLine("Please enter a last name:");
            string lastName = Console.ReadLine();
            Console.WriteLine("Please enter an age:");
            int age = int.Parse(Console.ReadLine());
            if (typeOfObject >= 5)
            {
                Console.WriteLine("Please enter a student number:");
                studentNumber = uint.Parse(Console.ReadLine());
                Console.WriteLine("Please enter an average grade:");
                averageGrade = float.Parse(Console.ReadLine());
                if (typeOfObject >= 7 && typeOfObject <= 9)
                {
                    Console.WriteLine("Please enter student current course:");
                    currentCourse = Console.ReadLine();
                    if (typeOfObject == 9)
                    {
                        Console.WriteLine("Please enter a numebr of visits:");
                        numberOfVisits = uint.Parse(Console.ReadLine());
                    }
                }
                else if (typeOfObject == 10)
                {
                    Console.WriteLine("Please enter dropout reason");
                    dropoutReason = Console.ReadLine();
                }
            }
            switch (typeOfObject)
            {
            case (1): temp = new Person(firstName, lastName, age); break;

            case (2): temp = new Trainer(firstName, lastName, age); break;

            case (3): temp = new JuniorTrainer(firstName, lastName, age); break;

            case (4): temp = new SeniorTrainer(firstName, lastName, age); break;

            case (5): temp = new Student(firstName, lastName, age, studentNumber, averageGrade); break;

            case (6): temp = new GraduateStudent(firstName, lastName, age, studentNumber, averageGrade); break;

            case (7): temp = new CurrentStudent(firstName, lastName, age, studentNumber, averageGrade, currentCourse); break;

            case (8): temp = new OnlineStudent(firstName, lastName, age, studentNumber, averageGrade, currentCourse); break;

            case (9): temp = new OnsiteStudent(firstName, lastName, age, studentNumber, averageGrade, currentCourse, numberOfVisits); break;

            case (10): temp = new DropoutStudent(firstName, lastName, age, studentNumber, averageGrade, dropoutReason); break;

            default:
                Console.WriteLine("Invalid object type");
                continue;
            }

            Console.WriteLine("Would you like to print the current object? Y\\N");
            checker = Console.ReadLine();
            if (checker == "Y" || checker == "y")
            {
                Console.WriteLine(temp.ToString());
            }
            if (typeOfObject >= 2 && typeOfObject <= 4)
            {
                Console.WriteLine("Would you like to add a course? Y\\N");
                checker = Console.ReadLine();
                if (checker == "Y" || checker == "y")
                {
                    Console.WriteLine("Please enter a course name:");
                    string  course      = Console.ReadLine();
                    Trainer tempTrainer = (Trainer)temp;
                    tempTrainer.CreateCourse(course);
                }
                if (typeOfObject == 4)
                {
                    Console.WriteLine("Would you like to delete a course? Y\\N");
                    checker = Console.ReadLine();
                    if (checker == "Y" || checker == "y")
                    {
                        Console.WriteLine("Please enter a course name:");
                        string        course      = Console.ReadLine();
                        SeniorTrainer tempTrainer = (SeniorTrainer)temp;
                        tempTrainer.DeleteCourse(course);
                    }
                }
            }
            if (typeOfObject == 10)
            {
                Console.WriteLine("Would you like to reapply? Y\\N");
                checker = Console.ReadLine();
                if (checker == "Y" || checker == "y")
                {
                    DropoutStudent tempStudent = (DropoutStudent)temp;
                    tempStudent.Reapply();
                }
            }
            softUniPeople.Add(temp);
            Console.WriteLine("Would you like to add another object? Y\\N");
            checker = Console.ReadLine();
        } while (checker != "N" && checker != "n");

        softUniPeople.Where(p => p is CurrentStudent).OrderBy(p => ((CurrentStudent)p).AverageGrade).ToList().ForEach(p => Console.WriteLine(p.ToString()));
    }
示例#13
0
        static void Main()
        {
            Person person1 = new Person("Gosho", "Minchev", 66);
            Person person2 = new Person("Pesho", "Genchev", 26);
            Person person3 = new Person("Mityo", "Pishtovliev", 36);
            List<Person> persons = new List<Person> { person1, person2, person3 };

            Student student1 = new Student("Misho", "Goranov", 23, "90012315", 4.56);
            Student student2 = new Student("Maya", "Petrova", 28, "90013315", 5.50);
            Student student3 = new Student("Petya", "Svilenova", 23, "90023315", 5.76);
            List<Student> students = new List<Student> { student1, student2, student3 };

            Trainer trainer1 = new Trainer("Svetlin", "Nakov", 33);
            Trainer trainer2 = new Trainer("Preslav", "Nakov", 35);
            Trainer trainer3 = new Trainer("Mario", "Peshev", 31);
            List<Trainer> trainers = new List<Trainer> { trainer1, trainer2, trainer3 };

            JuniorTrainer junior1 = new JuniorTrainer("Fil", "Kolev", 29);
            JuniorTrainer junior2 = new JuniorTrainer("Penka", "Borukova", 28);
            JuniorTrainer junior3 = new JuniorTrainer("Ivo", "Kotow", 30);
            List<JuniorTrainer> juniorTrainers = new List<JuniorTrainer> { junior1, junior2, junior3 };

            SeniorTrainer senior1 = new SeniorTrainer("Angel", "Georgiev", 31);
            SeniorTrainer senior2 = new SeniorTrainer("Atanas", "Rusenov", 26);
            SeniorTrainer senior3 = new SeniorTrainer("Bogomil", "Dimitrov", 30);
            List<SeniorTrainer> seniorTrainers = new List<SeniorTrainer> { senior1, senior2, senior3 };

            CurrentStudent currentSt1 = new CurrentStudent("Georgi", "Petkov", 21, "900432114", 5.25, "Advanced JavaScript");
            CurrentStudent currentSt2 = new CurrentStudent("Aneliya", "Borisova", 20, "900422114", 4.56, "Java Basics");
            CurrentStudent currentSt3 = new CurrentStudent("Sasha", "Grey", 29, "900434315", 3.69, "Avanced C#");
            List<CurrentStudent> currentStudents = new List<CurrentStudent> { currentSt1, currentSt2, currentSt3 };

            CurrentOnlineStudent currOnlineSt1 = new CurrentOnlineStudent("Merry", "Poppins", 22, "900682115", 3.50, "OOP");
            CurrentOnlineStudent currOnlineSt2 = new CurrentOnlineStudent("Aaron", "Turner", 32, "900542115", 5.50, "Database Applications");
            CurrentOnlineStudent currOnlineSt3 = new CurrentOnlineStudent("Nashmat", "Kodarov", 22, "900684315", 5.24, "Web Fundamentals");
            List<CurrentOnlineStudent> currentOnlineStudents = new List<CurrentOnlineStudent> { currOnlineSt1, currOnlineSt2, currOnlineSt3 };

            CurrentOnsiteStudent currOnsiteSt1 = new CurrentOnsiteStudent("Masha", "Medvedevna", 18, "900543215", 4.15, "Java Basics");
            CurrentOnsiteStudent currOnsiteSt2 = new CurrentOnsiteStudent("Ivana", "Kotareva", 29, "900693215", 5.80, "Java Advanced");
            CurrentOnsiteStudent currOnsiteSt3 = new CurrentOnsiteStudent("Ismail", "Programoglu", 18, "900541115", 4.95, "C# Advanced");
            List<CurrentOnsiteStudent> currentOnsiteStudents = new List<CurrentOnsiteStudent> { currOnsiteSt1, currOnsiteSt2, currOnsiteSt3 };

            GraduateStudent gradStudent1 = new GraduateStudent("Koycho", "Nashmatov", 25, "900122114", 5.15);
            GraduateStudent gradStudent2 = new GraduateStudent("Katya", "Yavorova", 45, "900002114", 5.45);
            GraduateStudent gradStudent3 = new GraduateStudent("Gospodin", "Nashmatov", 26, "900122214", 5.59);
            List<GraduateStudent> graduateStudents = new List<GraduateStudent> { gradStudent1, gradStudent2, gradStudent3 };

            DropoutStudent dropStudent1 = new DropoutStudent("Ganka", "Prostakieva", 19, "9001235214", 2.85, "Low grades");
            DropoutStudent dropStudent2 = new DropoutStudent("Vasil", "Sarikov", 29, "9001015214", 2.40, "Low grades");
            DropoutStudent dropStudent3 = new DropoutStudent("Daniel", "Zarezliev", 19, "9001235214", 4.85, "Going to the Mars colony.");
            List<DropoutStudent> dropoutStudents = new List<DropoutStudent> { dropStudent1, dropStudent2, dropStudent3 };

            List<Person> database = new List<Person>();
            database.AddRange(persons);
            database.AddRange(students);
            database.AddRange(trainers);
            database.AddRange(juniorTrainers);
            database.AddRange(seniorTrainers);
            database.AddRange(currentStudents);
            database.AddRange(currentOnlineStudents);
            database.AddRange(currentOnsiteStudents);
            database.AddRange(graduateStudents);
            database.AddRange(dropoutStudents);

            var currentStudentsSortedByAvgGrade = database.Where(x => x is CurrentStudent).Cast<CurrentStudent>().OrderByDescending(x => x.AverageGrade);

            foreach (Student student in currentStudentsSortedByAvgGrade)
            {
                Console.WriteLine("Name: {0} {1}", student.FirstName, student.LastName);
                Console.WriteLine("Average Grade: {0}", student.AverageGrade);
            }
        }
示例#14
0
    public static void Main()
    {
        SeniorTrainer nakov = new SeniorTrainer(
            "Svetlin",
            "Nakov",
            22); // forever young :D
        Trainer vGeorgiev = new JuniorTrainer(
            "Vladimir",
            "Georgiev",
            20);

        Student graduated = new GraduateStudent(
            "Ivan",
            "Ivanov",
            25,
            2213435,
            (float)5.60);
        Student dropoutedOne = new DropoutStudent(
            "Vasil",
            "Vasilev",
            21,
            11643,
            (float)2.41,
            "unpaid semester");

        DropoutStudent dropoutedTwo = new DropoutStudent(
            "Nikolay",
            "Nikolov",
            26,
            4566789,
            (float)2.25,
            "bad results");

        Student currentOne = new OnsiteStudent("Petyr", "Petrov", 19, 411313, (float)4.67, "OOP", 2);
        Student currentTwo = new OnlineStudent(
            "Stoyan",
            "Stoyanov",
            32,
            2323439,
            (float)5.19,
            "Java Basics");

        List <Person> persons = new List <Person>()
        {
            nakov, vGeorgiev, graduated, dropoutedOne, dropoutedTwo, currentOne, currentTwo
        };

        Console.WriteLine("Current students:");

        // sort and call ToString method
        persons.Where(p => p is CurrentStudent).OrderBy(p => ((CurrentStudent)p).AverageGrade).ToList().ForEach(p => Console.WriteLine(p.ToString()));

        // create/delete courses
        Console.WriteLine("Created/deleted courses:");
        Console.WriteLine(vGeorgiev.CreateCourse("OPP"));
        Console.WriteLine(nakov.DeleteCourse("Java Basics"));

        Console.WriteLine();

        // reaply students
        Console.WriteLine("Reaply students:");
        Console.WriteLine(dropoutedTwo.Reaplly());
    }
    static void Main()
    {
        Random randGenerator = new Random();
        Console.Write("Input the number of people. ");
        int peopleCount = int.Parse(Console.ReadLine());
        Console.WriteLine();

        Person[] people = new Person[peopleCount];
        List<CurrentStudent> students = new List<CurrentStudent>();

        Console.WriteLine(new string('-', 40));
        Console.WriteLine("People");
        Console.WriteLine(new string('-', 40));

        int studentID = 0;
        for (int index = 0; index < peopleCount; index++)
        {
            string firstName = ((firstNames)randGenerator.Next(9)).ToString();
            string lastName = ((lastNames)randGenerator.Next(9)).ToString();
            string type = ((types)randGenerator.Next(6)).ToString();
            int age = randGenerator.Next(80);
            double averageGrade = (randGenerator.NextDouble() * 4) + 2;
            string course = ((courses)randGenerator.Next(5)).ToString();

            switch (type)
            {
                case "JuniorTrainer":
                    people[index] = new JuniorTrainer(firstName, lastName, age);
                    break;
                case "SeniorTrainer":
                    people[index] = new SeniorTrainer(firstName, lastName, age);
                    break;
                case "GraduateStudent":
                    people[index] = new GraduateStudent(firstName, lastName, age, studentID, averageGrade);
                    studentID++;
                    break;
                case "DropoutStudent":
                    people[index] = new DropoutStudent(firstName, lastName, age, studentID, averageGrade, "Being lazy...");
                    studentID++;
                    break;
                case "OnlineStudent":
                    people[index] = new OnlineStudent(firstName, lastName, age, studentID, averageGrade, course);
                    students.Add(new OnlineStudent(firstName, lastName, age, studentID, averageGrade, course));
                    studentID++;
                    break;
                default:
                    int numberOfVisits = randGenerator.Next(125);
                    people[index] = new OnsiteStudent(firstName, lastName, age, studentID, averageGrade, course, numberOfVisits);
                    students.Add(new OnsiteStudent(firstName, lastName, age, studentID, averageGrade, course, numberOfVisits));
                    studentID++;
                    break;
            }

            Console.WriteLine(people[index].ToString());
            Console.WriteLine();
        }

        Console.WriteLine(new string('-', 40));
        Console.WriteLine("Current Students Ranking");
        Console.WriteLine(new string('-', 40));

        students = students.OrderBy(s => s.AverageGrade).ToList();
        foreach (CurrentStudent student in students)
        {
            Console.WriteLine(student.ToString());
            Console.WriteLine();
        }
    }