Beispiel #1
0
        public int CompareTo(object obj)
        {
            BaseEmployee b = obj as BaseEmployee;

            if (b != null)
            {
                return(this._MonthlyPayment.CompareTo(b._MonthlyPayment));
            }
            else
            {
                throw new Exception("Невозможно сравнить два объекта");
            }
        }
Beispiel #2
0
        public void ArrayEmployee()
        {
            BaseEmployee[] workers = new BaseEmployee[4];

            workers[0] = new HourlyPayment(85, 1, "Максим");
            workers[1] = new FixedPayment(10000, 2, "Сергей");
            workers[2] = new HourlyPayment(60, 1, "Юрий");
            workers[3] = new FixedPayment(25000, 2, "Светлана");

            foreach (BaseEmployee worker in workers)
            {
                worker.PaymentCalculation();
            }

            Array.Sort(workers);
            Console.WriteLine("\nСортировка по месячной зарплате: \n ");
            foreach (BaseEmployee worker in workers)
            {
                Console.WriteLine("Месячная зарплата " + worker._MonthlyPayment + "|" + "имя " + worker._Name + "|" + "id" + worker._Id);
            }
        }