Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Salary1
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Employee> myJournal;
- int count = 0;
- myJournal = CreateListWorkers();
- Console.WriteLine("Salary from this month:\n");
- //var sortJournal = LINQSort(myJournal);
- myJournal.Sort();
- myJournal.Reverse();
- foreach (var item in myJournal)
- {
- count++;
- Console.WriteLine("{0}) {1}: {2:C}", count, item.Name, item.Salary);
- }
- }
- private static List<Employee> CreateListWorkers()
- {
- List<Employee> workers = new List<Employee>();
- workers.Add(new FixedSalary("Roma Mak", 1000));
- workers.Add(new HoursSalary("Ivan Lisov", 4));
- workers.Add(new FixedSalary("Nikolay Murtov", 780));
- workers.Add(new HoursSalary("Svetlana Orekhova", 5.5));
- workers.Add(new FixedSalary("Diana Reva", 610));
- workers.Add(new HoursSalary("Oleg Lugniy", 5));
- workers.Add(new FixedSalary("Dmitriy Stok", 1190));
- workers.Add(new HoursSalary("Mila Werhova", 8));
- workers.Add(new FixedSalary("Roma Reakov", 1190));
- return workers;
- }
- //static IOrderedEnumerable<Employee> LINQSort(List<Employee> journal)
- //{
- // var sortJournal = from u in journal
- // orderby u.Salary descending
- // select u;
- // return sortJournal;
- //}
- }
- abstract class Employee : IComparable<Employee>
- {
- public string Name { get; set; }
- public double Tax { get; set; }
- public double Salary { get; set; }
- public Employee(string name, double tax)
- {
- this.Name = name;
- this.Tax = tax;
- averageSalary();
- }
- protected abstract double averageSalary();
- public int CompareTo(Employee obj)
- {
- return this.Salary.CompareTo(obj.Salary);
- }
- }
- class FixedSalary : Employee
- {
- public FixedSalary(string name, double salary)
- : base(name, salary)
- { }
- protected override double averageSalary()
- {
- Salary = Tax;
- return Salary;
- }
- }
- class HoursSalary : Employee
- {
- private const double rate = 20.8;
- private double hourOfDays = 8;
- public HoursSalary(string name, double salary)
- : base(name, salary)
- { }
- protected override double averageSalary()
- {
- Salary = rate * hourOfDays * Tax;
- return Salary;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement