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);
- foreach (var item in sortJournal)
- {
- 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", 870));
- 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
- select u;
- return sortJournal;
- }
- }
- abstract class 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 void averageSalary();
- }
- class FixedSalary : Employee
- {
- public FixedSalary(string name, double salary)
- : base(name, salary)
- { }
- protected override void averageSalary()
- {
- Salary = Tax;
- }
- }
- class HoursSalary : Employee
- {
- private const double rate = 20.8;
- private double hourOfDays = 8;
- public HoursSalary(string name, double salary)
- : base(name, salary)
- { }
- protected override void averageSalary()
- {
- Salary = rate * hourOfDays * Tax;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement