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;
- myJournal = CreateListWorkers();
- Console.WriteLine("Salary from this month:\n");
- myJournal = myJournal.OrderByDescending(a => a.Salary).ToList();
- for (int i = 0; i < myJournal.Count; i++)
- Console.WriteLine("{0}) {1}: {2:C}", i + 1, myJournal[i].Name, myJournal[i].Salary);
- Console.ReadKey();
- }
- 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("Dmitriy Stob", 1190));
- return workers;
- }
- }
- 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;
- Salary = Tax;
- averageSalary();
- }
- protected abstract double averageSalary();
- }
- class FixedSalary : Employee
- {
- public FixedSalary(string name, double salary)
- : base(name, salary)
- { }
- protected override double averageSalary()
- {
- 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()
- {
- return Salary *= rate * hourOfDays;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement