nikminer4sv

Untitled

Feb 2nd, 2023
778
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.42 KB | None | 0 0
  1. using System.Threading.Channels;
  2.  
  3. internal class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         int amountOfProjects = 5;
  8.         Engineer e = new Engineer("Nikita", 1000, amountOfProjects);
  9.         Console.WriteLine($"Зарплата инженера до вызова метода(проектов {amountOfProjects}): {e.CalculateIncome(1)}");
  10.         e.ChangeIncome();
  11.         Console.WriteLine($"Зарплата инженера после вызова метода: {e.CalculateIncome(1)}");
  12.  
  13.         double volume = 55000000;
  14.         Manager m = new Manager("Nikita", 1000, volume);
  15.         Console.WriteLine($"Зарплата менеджера до вызова метода(объем продаж {volume}): {m.CalculateIncome(1)}");
  16.         m.ChangeIncome(3000000);
  17.         Console.WriteLine($"Зарплата менеджера до после метода: {m.CalculateIncome(1)}");
  18.     }
  19. }
  20.  
  21. public class Employee
  22. {
  23.     protected string Name;
  24.     protected double P;
  25.  
  26.     public Employee(string name, double p)
  27.     {
  28.         Name = name;
  29.         P = p;
  30.     }
  31.  
  32.     public void SetName(string name)
  33.     {
  34.         this.Name = name;
  35.     }
  36.  
  37.     public void SetP(double p)
  38.     {
  39.         this.P = p;
  40.     }
  41.  
  42.     public string GetName()
  43.     {
  44.         return Name;
  45.     }
  46.  
  47.     public double GetP()
  48.     {
  49.         return P;
  50.     }
  51.  
  52.     public double CalculateIncome(double k)
  53.     {
  54.         return P * k;
  55.     }
  56. }
  57.  
  58. public class Manager : Employee
  59. {
  60.     private double Volume;
  61.    
  62.     public Manager(string name, double p, double volume) : base(name, p)
  63.     {
  64.         Volume = volume;
  65.     }
  66.  
  67.     public void SetVolume(double volume)
  68.     {
  69.         Volume = volume;
  70.     }
  71.  
  72.     public double GetVolume()
  73.     {
  74.         return Volume;
  75.     }
  76.  
  77.     public void ChangeIncome(double h)
  78.     {
  79.         if (Volume > h)
  80.         {
  81.             P += 0.01 * h;
  82.         }
  83.     }
  84. }
  85.  
  86. public class Engineer : Employee
  87. {
  88.     private int AmountOfProjects;
  89.    
  90.     public Engineer(string name, double p, int amountOfProjects) : base(name, p)
  91.     {
  92.         AmountOfProjects = amountOfProjects;
  93.     }
  94.  
  95.     public void SetAmountOfProjects(int amountOfProjects)
  96.     {
  97.         AmountOfProjects = amountOfProjects;
  98.     }
  99.  
  100.     public int GetAmountOfProjects()
  101.     {
  102.         return AmountOfProjects;
  103.     }
  104.  
  105.     public void ChangeIncome()
  106.     {
  107.         P += AmountOfProjects * 4.8;
  108.     }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment