nikminer4sv

Untitled

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