public int CompareTo(object obj) { if (obj == null) { return(1); } ArrayEmployee strarr = obj as ArrayEmployee; if (strarr != null) { return(this.strtemp.CompareTo(strarr.strtemp)); } else { throw new ArgumentException("Object is not a ArrayEmployee"); } }
static void Main(string[] args) { const double fixpayment = 50000; const double timepayment = 350; const string pathFixEmployeeDB = @"EmployeeDataBase\test.txt"; const string pathTimeEmployeeDB = @"EmployeeDataBase\TimeEmpoyeeDataBase.txt"; EmployeeFixPayment fixEmloyee = new EmployeeFixPayment(); EmployeeTimePayment timeEmployee = new EmployeeTimePayment(); Console.WriteLine($"Среднемесячная фиксированная заработная плата = {fixEmloyee.Pay(fixpayment)}"); Console.WriteLine($"Среднемесячная повременная заработная плата = {timeEmployee.Pay(timepayment)}\n"); fixEmloyee.ReadEmployeeDB(pathFixEmployeeDB); fixEmloyee.ToDisplay(); timeEmployee.ReadEmployeeDB(pathTimeEmployeeDB); timeEmployee.ToDisplay(); //1.с *Реализовать интерфейсы для возможности сортировки массива используя Array.Sort(). { ArrayList arrayEmployee = new ArrayList(); for (int i = 0; i < timeEmployee.strarr.Count; i++) { ArrayEmployee ae = new ArrayEmployee(); ae.Tostrtemp = timeEmployee.strarr[i].ToString(); arrayEmployee.Add(ae); } Console.WriteLine("1.c) Реализация сортировки"); arrayEmployee.Sort(); foreach (ArrayEmployee t in arrayEmployee) { Console.WriteLine("\t" + t.Tostrtemp); } } Console.ReadKey(); }