using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace лаба_4 { public interface i1 { string zarp(); } class main : i1 { public int staj; public string dolj; public double zarpl=0; public main(int staj, string dolj) { this.staj = staj; this.dolj = dolj; } public string zarp() { zarpl = staj * 24 / 8 + 65.70 + 1600; return zarpl.ToString(); } } class nach : main { public nach(int staj):base(staj,"Насяльнике") { } } class manadger : main { public manadger(int staj):base(staj,"Менеджер") { } } class bukhg : main { public bukhg(int staj):base(staj,"Бухгалтер") { } } class Program { static void Main(string[] args) { List
zarp = new List
(); string answer = "0"; while (answer != "нет") { Console.WriteLine("Какого сотрудника добавить?\n1.Насяльнике\n2.Менеджер\n3.Бухгалтер"); int c1 = int.Parse(Console.ReadLine()); while (c1 > 3 || c1 < 0) { Console.WriteLine("попробуйте еще раз"); c1 = int.Parse(Console.ReadLine()); } switch (c1) { case 1: { Console.WriteLine("Введите стаж"); int st = int.Parse(Console.ReadLine()); zarp.Add(new nach(st)); break; } case 2: { Console.WriteLine("Введите стаж"); int st = int.Parse(Console.ReadLine()); zarp.Add(new manadger(st)); break; } case 3: { Console.WriteLine("Введите стаж"); int st = int.Parse(Console.ReadLine()); zarp.Add(new bukhg(st)); break; } } Console.WriteLine("Добавить сотрудника?"); answer = Console.ReadLine(); Console.Clear(); } Console.WriteLine("№ |должность |Стаж|Зарплата|"); for (int i = 0; i < zarp.Count; i++) { zarp[i].zarp(); Console.WriteLine("{0,4}|{1,11}|{2,4}|{3,8}", i+1,zarp[i].dolj,zarp[i].staj,zarp[i].zarpl); } Console.WriteLine("Хотите удалить элемент ?"); answer=Console.ReadLine(); while(answer=="да") { int n=int.Parse(Console.ReadLine()); zarp.RemoveAt(n-1); Console.Clear(); Console.WriteLine("№ |должность |Стаж|Зарплата|"); for (int i = 0; i < zarp.Count; i++) { Console.WriteLine("{0,4}|{1,11}|{2,4}|", i, zarp[i].dolj,zarp[i].staj); } Console.WriteLine("Удалить еще 1 элемент"); answer = Console.ReadLine(); } Console.ReadKey(); } } }