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;
- using System.Collections;
- namespace rep_c_sharp
- {
- class Program
- {
- abstract class Cadre
- {
- private string name;
- public Cadre(string Name)
- {
- name = Name;
- }
- public string Name
- {
- get;
- set;
- }
- public abstract void ShowPosition();
- }
- class Workman : Cadre
- {
- private double salary;
- public Workman(string Name, double Salary)
- :base(Name)
- {
- this.Salary = Salary;
- this.Name = Name;
- }
- public double Salary
- {
- get;
- set;
- }
- public override void ShowPosition()
- {
- Console.WriteLine(string.Format("Рабочий с именем {0} и зарплатой {1}", Name, Salary));
- }
- }
- class Admin : Workman
- {
- private int age;
- public Admin(string Name, double Salary, int Age)
- :base(Name, Salary)
- {
- this.Salary = Salary;
- age = Age;
- }
- public int Age
- {
- get;
- set;
- }
- public override void ShowPosition()
- {
- Console.WriteLine(string.Format("Администратор с именем {0} и зарплатой {1} и возрастом {2}", Name, Salary, age));
- }
- }
- class Engineer : Workman
- {
- private int category;
- public Engineer(string Name, double Salary, int Category)
- :base(Name, Salary)
- {
- this.Salary = Salary;
- category = Category;
- }
- public int Category
- {
- get;
- set;
- }
- public override void ShowPosition()
- {
- Console.WriteLine(string.Format("Инженер с именем {0} и зарплатой {1} и категорией {2}", Name, Salary, category));
- }
- }
- static void Main(string[] args)
- {
- Cadre c = new Workman("Иван", 25000);
- c.ShowPosition();
- c = new Engineer("Максим", 34000, 3);
- c.ShowPosition();
- c = new Admin("Анна", 40000, 23);
- c.ShowPosition();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement