Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Collections;
  7.  
  8. namespace rep_c_sharp
  9. {
  10.     class Program
  11.     {
  12.         abstract class Cadre
  13.         {
  14.             private string name;
  15.  
  16.             public Cadre(string Name)
  17.             {
  18.                 name = Name;
  19.             }
  20.  
  21.             public string Name
  22.             {
  23.                 get;
  24.                 set;
  25.             }
  26.  
  27.             public abstract void ShowPosition();
  28.         }
  29.  
  30.         class Workman : Cadre
  31.         {
  32.             private double salary;
  33.  
  34.             public Workman(string Name, double Salary)
  35.                 :base(Name)
  36.             {
  37.                 this.Salary = Salary;
  38.                 this.Name = Name;
  39.             }
  40.  
  41.             public double Salary
  42.             {
  43.                 get;
  44.                 set;
  45.             }
  46.  
  47.             public override void ShowPosition()
  48.             {
  49.                 Console.WriteLine(string.Format("Рабочий с именем {0} и зарплатой {1}", Name, Salary));
  50.             }
  51.         }
  52.  
  53.         class Admin : Workman
  54.         {
  55.             private int age;
  56.  
  57.             public Admin(string Name, double Salary, int Age)
  58.                 :base(Name, Salary)
  59.             {
  60.                 this.Salary = Salary;
  61.                 age = Age;
  62.             }
  63.  
  64.             public int Age
  65.             {
  66.                 get;
  67.                 set;
  68.             }
  69.  
  70.             public override void ShowPosition()
  71.             {
  72.                 Console.WriteLine(string.Format("Администратор с именем {0} и зарплатой {1} и возрастом {2}", Name, Salary, age));
  73.             }
  74.         }
  75.  
  76.         class Engineer : Workman
  77.         {
  78.             private int category;
  79.  
  80.             public Engineer(string Name, double Salary, int Category)
  81.                 :base(Name, Salary)
  82.             {
  83.                 this.Salary = Salary;
  84.                 category = Category;
  85.             }
  86.             public int Category
  87.             {
  88.                 get;
  89.                 set;
  90.             }
  91.  
  92.             public override void ShowPosition()
  93.             {
  94.                 Console.WriteLine(string.Format("Инженер с именем {0} и зарплатой {1} и категорией {2}", Name, Salary, category));
  95.             }
  96.         }
  97.  
  98.         static void Main(string[] args)
  99.         {
  100.             Cadre c = new Workman("Иван", 25000);
  101.             c.ShowPosition();
  102.            
  103.             c = new Engineer("Максим", 34000, 3);
  104.             c.ShowPosition();
  105.  
  106.             c = new Admin("Анна", 40000, 23);
  107.             c.ShowPosition();
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement