4DM3M

17

Jan 3rd, 2022
844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class Program
  5. {
  6.  
  7.     public class School
  8.     {
  9.         int countOfPupils;
  10.         string schoolName, directorName;
  11.         List<string> awards;
  12.         bool hasCanteen;
  13.  
  14.         public School()
  15.         {
  16.             countOfPupils = 0;
  17.             schoolName = "some school";
  18.             directorName = "some director";
  19.             awards = new List<string>();
  20.             hasCanteen = false;
  21.         }
  22.  
  23.         public School(string schoolName, string directorName, int countOfPupils, bool hasCanteen)
  24.         {
  25.             this.schoolName = schoolName;
  26.             this.directorName = directorName;
  27.             this.countOfPupils = countOfPupils;
  28.             this.hasCanteen = hasCanteen;
  29.             this.awards = new List<string>();
  30.         }
  31.  
  32.         public void NewAward(string newAward)
  33.         {
  34.             this.awards.Add(newAward);
  35.         }
  36.  
  37.         public void GetAwards()
  38.         {
  39.             Console.WriteLine("Awards List:");
  40.             for (int i = 0; i < this.awards.Count; i++)
  41.             {
  42.                 Console.WriteLine(this.awards[i]);
  43.             }
  44.         }
  45.  
  46.         public void ChangeDirector(string newDirectorName)
  47.         {
  48.             this.directorName = newDirectorName;
  49.         }
  50.  
  51.         public void BuildCanteen()
  52.         {
  53.             if (!this.hasCanteen)
  54.             {
  55.                 this.hasCanteen = true;
  56.                 Console.WriteLine("Была построенна столовая");
  57.             }
  58.             else
  59.             {
  60.                 Console.WriteLine("Столовая уже есть");
  61.             }
  62.         }
  63.  
  64.         public void AddPupil()
  65.         {
  66.             this.countOfPupils++;
  67.         }
  68.  
  69.         public void AddPupil(int count)
  70.         {
  71.             this.countOfPupils += count;
  72.         }
  73.  
  74.         public void ChangeSchoolName(string name)
  75.         {
  76.             this.schoolName = name;
  77.         }
  78.  
  79.         public void Info()
  80.         {
  81.             Console.WriteLine($"Название школы: {this.schoolName}\n" +
  82.                 $"Директор школы: {this.directorName}\n" +
  83.                 $"Количество учащихся: {this.countOfPupils}\n" +
  84.                 $"Количество наград: {this.awards.Count}\n" +
  85.                 $"Наличие столовой: {this.hasCanteen}");
  86.         }
  87.     }
  88.  
  89.     public class University
  90.     {
  91.         int CountOfStudents;
  92.         string UniversityName, RectorName;
  93.         List<string> awards;
  94.         bool hasCanteen;
  95.  
  96.         public University()
  97.         {
  98.             CountOfStudents = 0;
  99.             UniversityName = "some University";
  100.             RectorName = "some rector";
  101.             awards = new List<string>();
  102.             hasCanteen = false;
  103.         }
  104.  
  105.         public University(string schoolName, string directorName, int countOfPupils, bool hasCanteen)
  106.         {
  107.             this.UniversityName = schoolName;
  108.             this.RectorName = directorName;
  109.             this.CountOfStudents = countOfPupils;
  110.             this.hasCanteen = hasCanteen;
  111.             this.awards = new List<string>();
  112.         }
  113.  
  114.         public void NewAward(string newAward)
  115.         {
  116.             this.awards.Add(newAward);
  117.         }
  118.  
  119.         public void GetAwards()
  120.         {
  121.             Console.WriteLine("Awards List:");
  122.             for (int i = 0; i < this.awards.Count; i++)
  123.             {
  124.                 Console.WriteLine(this.awards[i]);
  125.             }
  126.         }
  127.  
  128.         public void ChangeDirector(string newDirectorName)
  129.         {
  130.             this.RectorName = newDirectorName;
  131.         }
  132.  
  133.         public void BuildCanteen()
  134.         {
  135.             if (!this.hasCanteen)
  136.             {
  137.                 this.hasCanteen = true;
  138.                 Console.WriteLine("Была построенна столовая");
  139.             }
  140.             else
  141.             {
  142.                 Console.WriteLine("Столовая уже есть");
  143.             }
  144.         }
  145.  
  146.         public void AddPupil()
  147.         {
  148.             this.CountOfStudents++;
  149.         }
  150.  
  151.         public void AddPupil(int count)
  152.         {
  153.             this.CountOfStudents += count;
  154.         }
  155.  
  156.         public void ChangeSchoolName(string name)
  157.         {
  158.             this.UniversityName = name;
  159.         }
  160.  
  161.         public void Info()
  162.         {
  163.             Console.WriteLine($"Название университета: {this.UniversityName}\n" +
  164.                 $"Директор университета: {this.RectorName}\n" +
  165.                 $"Количество учащихся: {this.CountOfStudents}\n" +
  166.                 $"Количество наград: {this.awards.Count}\n" +
  167.                 $"Наличие столовой: {this.hasCanteen}");
  168.         }
  169.     }
  170.  
  171.     public class College
  172.     {
  173.         int CountOfStudents;
  174.         string UniversityName, director;
  175.         List<string> awards;
  176.         bool hasCanteen;
  177.  
  178.         public College()
  179.         {
  180.             CountOfStudents = 0;
  181.             UniversityName = "some college";
  182.             director = "some director";
  183.             awards = new List<string>();
  184.             hasCanteen = false;
  185.         }
  186.  
  187.         public College(string schoolName, string directorName, int countOfPupils, bool hasCanteen)
  188.         {
  189.             this.UniversityName = schoolName;
  190.             this.director = directorName;
  191.             this.CountOfStudents = countOfPupils;
  192.             this.hasCanteen = hasCanteen;
  193.             this.awards = new List<string>();
  194.         }
  195.  
  196.         public void NewAward(string newAward)
  197.         {
  198.             this.awards.Add(newAward);
  199.         }
  200.  
  201.         public void GetAwards()
  202.         {
  203.             Console.WriteLine("Awards List:");
  204.             for (int i = 0; i < this.awards.Count; i++)
  205.             {
  206.                 Console.WriteLine(this.awards[i]);
  207.             }
  208.         }
  209.  
  210.         public void ChangeDirector(string newDirectorName)
  211.         {
  212.             this.director = newDirectorName;
  213.         }
  214.  
  215.         public void BuildCanteen()
  216.         {
  217.             if (!this.hasCanteen)
  218.             {
  219.                 this.hasCanteen = true;
  220.                 Console.WriteLine("Была построенна столовая");
  221.             }
  222.             else
  223.             {
  224.                 Console.WriteLine("Столовая уже есть");
  225.             }
  226.         }
  227.  
  228.         public void AddPupil()
  229.         {
  230.             this.CountOfStudents++;
  231.         }
  232.  
  233.         public void AddPupil(int count)
  234.         {
  235.             this.CountOfStudents += count;
  236.         }
  237.  
  238.         public void ChangeSchoolName(string name)
  239.         {
  240.             this.UniversityName = name;
  241.         }
  242.  
  243.         public void Info()
  244.         {
  245.             Console.WriteLine($"Название колледжа: {this.UniversityName}\n" +
  246.                 $"Директор колледжа: {this.director}\n" +
  247.                 $"Количество учащихся: {this.CountOfStudents}\n" +
  248.                 $"Количество наград: {this.awards.Count}\n" +
  249.                 $"Наличие столовой: {this.hasCanteen}");
  250.         }
  251.     }
  252.  
  253.     public class SpecSchool
  254.     {
  255.         int CountOfStudents;
  256.         string SpecSchoolName, director;
  257.         List<string> awards;
  258.         bool hasCanteen;
  259.  
  260.         public SpecSchool()
  261.         {
  262.             CountOfStudents = 0;
  263.             SpecSchoolName = "some specSchool";
  264.             director = "some director";
  265.             awards = new List<string>();
  266.             hasCanteen = false;
  267.         }
  268.  
  269.         public SpecSchool(string schoolName, string directorName, int countOfPupils, bool hasCanteen)
  270.         {
  271.             this.SpecSchoolName = schoolName;
  272.             this.director = directorName;
  273.             this.CountOfStudents = countOfPupils;
  274.             this.hasCanteen = hasCanteen;
  275.             this.awards = new List<string>();
  276.         }
  277.  
  278.         public void NewAward(string newAward)
  279.         {
  280.             this.awards.Add(newAward);
  281.         }
  282.  
  283.         public void GetAwards()
  284.         {
  285.             Console.WriteLine("Awards List:");
  286.             for (int i = 0; i < this.awards.Count; i++)
  287.             {
  288.                 Console.WriteLine(this.awards[i]);
  289.             }
  290.         }
  291.  
  292.         public void ChangeDirector(string newDirectorName)
  293.         {
  294.             this.director = newDirectorName;
  295.         }
  296.  
  297.         public void BuildCanteen()
  298.         {
  299.             if (!this.hasCanteen)
  300.             {
  301.                 this.hasCanteen = true;
  302.                 Console.WriteLine("Была построенна столовая");
  303.             }
  304.             else
  305.             {
  306.                 Console.WriteLine("Столовая уже есть");
  307.             }
  308.         }
  309.  
  310.         public void AddPupil()
  311.         {
  312.             this.CountOfStudents++;
  313.         }
  314.  
  315.         public void AddPupil(int count)
  316.         {
  317.             this.CountOfStudents += count;
  318.         }
  319.  
  320.         public void ChangeSchoolName(string name)
  321.         {
  322.             this.SpecSchoolName = name;
  323.         }
  324.  
  325.         public void Info()
  326.         {
  327.             Console.WriteLine($"Название училища: {this.SpecSchoolName}\n" +
  328.                 $"Директор училища: {this.director}\n" +
  329.                 $"Количество учащихся: {this.CountOfStudents}\n" +
  330.                 $"Количество наград: {this.awards.Count}\n" +
  331.                 $"Наличие столовой: {this.hasCanteen}");
  332.         }
  333.     }
  334.  
  335.     public class Office
  336.     {
  337.         string officeName;
  338.         int countOfOrders, countOfWorkers;
  339.         List<string> assortiment;
  340.         bool hasFood;
  341.  
  342.         public Office()
  343.         {
  344.             this.officeName = "some Office";
  345.             this.hasFood = false;
  346.             this.countOfOrders = 0;
  347.             this.countOfOrders = 0;
  348.             this.assortiment = new List<string>();
  349.         }
  350.  
  351.         public Office(string officeName, int countOfWorkers, bool hasFood)
  352.         {
  353.             this.officeName = officeName;
  354.             this.countOfWorkers = countOfWorkers;
  355.             this.hasFood = hasFood;
  356.             this.assortiment = new List<string>();
  357.             this.countOfOrders = 0;
  358.         }
  359.  
  360.         public void GetOrder(int count)
  361.         {
  362.             this.countOfOrders += count;
  363.         }
  364.  
  365.         public void ServeOrders()
  366.         {
  367.             Console.WriteLine($"Заказов в очереди: {this.countOfOrders}");
  368.             this.countOfOrders -= this.countOfWorkers;
  369.  
  370.             if (countOfOrders <= 0)
  371.             {
  372.                 Console.WriteLine("Все заказы выполенны");
  373.                 this.countOfOrders = 0;
  374.             }
  375.             else
  376.             {
  377.                 Console.WriteLine($"Осталось заказов: {this.countOfOrders}");
  378.             }
  379.         }
  380.  
  381.         public void AddAssortiment(string someProduct, bool isFood)
  382.         {
  383.             this.assortiment.Add(someProduct);
  384.             if (!this.hasFood && isFood)
  385.             {
  386.                 this.hasFood = true;
  387.             }
  388.         }
  389.  
  390.         public void PrintAssortiment()
  391.         {
  392.             Console.WriteLine("Assortiment:");
  393.  
  394.             if (this.assortiment.Count == 0)
  395.             {
  396.                 Console.WriteLine("Empty");
  397.             }
  398.  
  399.             for (int i = 0; i < this.assortiment.Count; i++)
  400.             {
  401.                 Console.WriteLine(this.assortiment[i]);
  402.             }
  403.         }
  404.  
  405.         public void HireMan(int count)
  406.         {
  407.             this.countOfWorkers += count;
  408.         }
  409.  
  410.         public void HireMan()
  411.         {
  412.             this.countOfWorkers++;
  413.         }
  414.  
  415.         public void Info()
  416.         {
  417.             Console.WriteLine($"Название канцелярской: {this.officeName}\n" +
  418.                 $"Количество работников: {this.countOfWorkers}\n" +
  419.                 $"Товаров в ассортименте: {this.assortiment.Count}\n" +
  420.                 $"Активных заказов: {this.countOfOrders}\n" +
  421.                 $"Еда в ассортименте: {this.hasFood}");
  422.         }
  423.  
  424.     }
  425.  
  426.     delegate void voidDelegateNoParams();
  427.     delegate void voidDelegateStringParams(string source);
  428.  
  429.     static void Main()
  430.     {
  431.         School school = new("Школа", "Абрамов", 10, false);
  432.         //!!!
  433.         voidDelegateNoParams delegate1 = () =>
  434.         {
  435.             school.GetAwards();
  436.             school.BuildCanteen();
  437.             school.BuildCanteen();
  438.             school.Info();
  439.         };
  440.         //!!!
  441.         school.NewAward("молодцы");
  442.        
  443.         delegate1.Invoke();
  444.        
  445.         Console.WriteLine();
  446.  
  447.         University university = new("БГТУ", "Наумов", 200, true);
  448.         //!!!
  449.         voidDelegateNoParams delegate2 = () =>
  450.         {
  451.             university.GetAwards();
  452.             university.Info();
  453.             university.NewAward("Лучший университет");
  454.             university.NewAward("Самый лучий университет");
  455.             university.NewAward("Ну правда самый лучший университет");
  456.         };
  457.         //!!!
  458.         delegate2.Invoke();
  459.        
  460.         Console.WriteLine();
  461.  
  462.         College mrk = new("Минский радиотехнический колледж", "кто-то новый", 1000, true);
  463.         mrk.NewAward("молодцы");
  464.         mrk.GetAwards();
  465.         Console.WriteLine();
  466.         mrk.BuildCanteen();
  467.         mrk.Info();
  468.         Console.WriteLine();
  469.  
  470.         SpecSchool PTU = new("Училище имени ______", "Иванов", 2, false);
  471.         PTU.NewAward("молодцы");
  472.         PTU.GetAwards();
  473.         Console.WriteLine();
  474.         PTU.Info();
  475.         Console.WriteLine();
  476.  
  477.         Office office = new Office("Печатная", 4, false);
  478.         office.AddAssortiment("Апельсинки", true);
  479.         office.HireMan();
  480.         office.GetOrder(3);
  481.         office.ServeOrders();
  482.         office.PrintAssortiment();
  483.         office.Info();
  484.     }
  485. }
  486.  
Advertisement
Add Comment
Please, Sign In to add comment