static void Main()
 {
     Student studentOne = new Student("Mitko", "Mavrodiev", "asdsf");
     Student studentTwo = new Student("Filip", "Karlov", "12345");
     Student studentThree = new Student("Sezgin", "Petrov","aweqr");
     Student studentFour = new Student("Marta", "Karailianova", "19845");
     Student studentFive = new Student("Velichka", "Rambova", "16294");
     Student studentSix = new Student("Stavri", "Mavzuleev", "qwrqw");
     Student studentSeven = new Student("Silviq", "Djangova", "14243");
     Student studentEight = new Student("Roberto", "Haralambiev", "wqrat");
     Student studentNine = new Student("Hristomira", "Nikolaeva", "11455");
     Student studentTen = new Student("Zimbru", "Cesekaev", "grgfv");
     List<Student> students = new List<Student>();
     students.Add(studentOne);
     students.Add(studentTwo);
     students.Add(studentThree);
     students.Add(studentFour);
     students.Add(studentFive);
     students.Add(studentSix);
     students.Add(studentSeven);
     students.Add(studentEight);
     students.Add(studentNine);
     students.Add(studentTen);
     List<Student> sortedStudents = students.OrderBy(s => s.FacultyNumber).ToList();
     //foreach (var student in sortedStudents)
     //{
     //    Console.WriteLine(student);
     //}
     Worker workerOne = new Worker("Marto", "Grancharov", 50.35m, 6);
     Worker workerTwo = new Worker("Ianislav", "Marianov", 105.50m, 7);
     Worker workerThree = new Worker("Gonzo", "Levskarski", 10m, 11);
     Worker workerFour = new Worker("Bojana", "Georgieva", 300m, 3.30);
     Worker workerFive = new Worker("Petra", "Miniorska", 500m, 1.30);
     Worker workerSix = new Worker("Vaska", "Bojilova", 30.5m, 5);
     Worker workerSeven = new Worker("Hrizantema", "Jechkova", 330m, 4);
     Worker workerEight= new Worker("Vikoboi", "Karasemkov", 22m, 8.55);
     Worker workerNine = new Worker("Zevs", "Grumootvodov", 13m, 9.43);
     Worker workerTen = new Worker("Jivko", "Panteleimonov", 4m, 11.59);
     List<Worker> workers = new List<Worker>();
     workers.Add(workerOne);
     workers.Add(workerTwo);
     workers.Add(workerThree);
     workers.Add(workerFour);
     workers.Add(workerFive);
     workers.Add(workerSix);
     workers.Add(workerSeven);
     workers.Add(workerEight);
     workers.Add(workerNine);
     workers.Add(workerTen);
     List<Worker> sortedWorkers = workers.OrderByDescending(w => w.MoneyPerHour()).ToList();
     //foreach (var worker in sortedWorkers)
     //{
     //    //Console.WriteLine(worker.MoneyPerHour());
     //    Console.WriteLine(worker);
     //}
     List<Human> humans = new List<Human>();
     humans.AddRange(students);
     humans.AddRange(workers);
     List<Human> sortedHumans = humans.OrderBy(h => h.FirstName).ThenBy(h => h.LastName).ToList();
     //foreach (var human in sortedHumans)
     //{
     //    Console.WriteLine(human);
     //}
 }
예제 #2
0
        static void Main()
        {
            Student pesho = new Student("pesho", "petrov", "20144567");
            Student gosho = new Student("gosho", "georgiev", "20141730");
            Student misho = new Student("misho", "mishev", "20142589");
            Student ganka = new Student("ganka", "gancheva", "20146547");
            Student sanya = new Student("sanya", "mincheva", "20145285");
            Student ivan = new Student("ivan", "ivanov", "20145687");
            Student dimitar = new Student("dimitar", "dimitrov", "20143698");
            Student damyan = new Student("damyan", "damyanov", "20149634");
            Student mihail = new Student("mihail", "petrov", "20147415");
            Student doncho = new Student("doncho", "donchev", "20145612");

            List<Student> students = new List<Student>()
            {
                pesho,
                gosho,
                misho,
                ganka,
                sanya,
                ivan,
                dimitar, 
                damyan,
                mihail,
                doncho
            };

            Worker kosta = new Worker("kosta", "kostadinov", 282m, 8);
            Worker sancho = new Worker("sancho", "pansa", 382m, 6);
            Worker penka = new Worker("penka", "kostadinova", 243m, 4);
            Worker dimitrichka = new Worker("dimitrichka", "doynova", 152m, 2);
            Worker darina = new Worker("darina", "stamatova", 182m, 5);
            Worker zlatomir = new Worker("zlatomir", "zlatev", 242m, 7);
            Worker petar = new Worker("petar", "donchev", 482m, 6);
            Worker pencho = new Worker("pencho", "kubadinski", 578m, 9);
            Worker marko = new Worker("marko", "totev", 439m, 8);
            Worker kostadin = new Worker("kostadin", "haralambov", 658m, 9);

            List<Worker> workers = new List<Worker>()
            {
                kosta,
                sancho,
                penka,
                dimitrichka,
                darina,
                zlatomir,
                petar,
                pencho,
                marko,
                kostadin
            };

            Console.WriteLine("Sorted students");
            var sortedStudents = students.OrderBy(s => s.FacultyNumber);
            foreach (var student in sortedStudents)
            {
                Console.WriteLine(student);
            }

            Console.WriteLine();
            Console.WriteLine(new string('-', 50));
            Console.WriteLine();

            Console.WriteLine("Sorted workers");
            var sortedWorkers = workers.OrderByDescending(w => w.MoneyPerHour(Worker.WorkDays));
            foreach (var worker in workers)
            {
                Console.WriteLine(worker);
            }

            Console.WriteLine();
            Console.WriteLine(new string('-', 50));
            Console.WriteLine();

            Console.WriteLine("Sorted humans");
            List<Human> humans = new List<Human>();
            humans.AddRange(students);
            humans.AddRange(workers);
            var sortedHumans = humans
                .OrderBy(h => h.FirstName)
                .ThenBy(h => h.LastName);

            foreach (var human in sortedHumans)
            {
                Console.WriteLine(human);
            }
        }