Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class Program
- {
- public class School
- {
- int countOfPupils;
- string schoolName, directorName;
- List<string> awards;
- bool hasCanteen;
- public School()
- {
- countOfPupils = 0;
- schoolName = "some school";
- directorName = "some director";
- awards = new List<string>();
- hasCanteen = false;
- }
- public School(string schoolName, string directorName, int countOfPupils, bool hasCanteen)
- {
- this.schoolName = schoolName;
- this.directorName = directorName;
- this.countOfPupils = countOfPupils;
- this.hasCanteen = hasCanteen;
- this.awards = new List<string>();
- }
- public void NewAward(string newAward)
- {
- this.awards.Add(newAward);
- }
- public void GetAwards()
- {
- Console.WriteLine("Awards List:");
- for (int i = 0; i < this.awards.Count; i++)
- {
- Console.WriteLine(this.awards[i]);
- }
- }
- public void ChangeDirector(string newDirectorName)
- {
- this.directorName = newDirectorName;
- }
- public void BuildCanteen()
- {
- if (!this.hasCanteen)
- {
- this.hasCanteen = true;
- Console.WriteLine("Была построенна столовая");
- }
- else
- {
- Console.WriteLine("Столовая уже есть");
- }
- }
- public void AddPupil()
- {
- this.countOfPupils++;
- }
- public void AddPupil(int count)
- {
- this.countOfPupils += count;
- }
- public void ChangeSchoolName(string name)
- {
- this.schoolName = name;
- }
- public void Info()
- {
- Console.WriteLine($"Название школы: {this.schoolName}\n" +
- $"Директор школы: {this.directorName}\n" +
- $"Количество учащихся: {this.countOfPupils}\n" +
- $"Количество наград: {this.awards.Count}\n" +
- $"Наличие столовой: {this.hasCanteen}");
- }
- }
- public class University
- {
- int CountOfStudents;
- string UniversityName, RectorName;
- List<string> awards;
- bool hasCanteen;
- public University()
- {
- CountOfStudents = 0;
- UniversityName = "some University";
- RectorName = "some rector";
- awards = new List<string>();
- hasCanteen = false;
- }
- public University(string schoolName, string directorName, int countOfPupils, bool hasCanteen)
- {
- this.UniversityName = schoolName;
- this.RectorName = directorName;
- this.CountOfStudents = countOfPupils;
- this.hasCanteen = hasCanteen;
- this.awards = new List<string>();
- }
- public void NewAward(string newAward)
- {
- this.awards.Add(newAward);
- }
- public void GetAwards()
- {
- Console.WriteLine("Awards List:");
- for (int i = 0; i < this.awards.Count; i++)
- {
- Console.WriteLine(this.awards[i]);
- }
- }
- public void ChangeDirector(string newDirectorName)
- {
- this.RectorName = newDirectorName;
- }
- public void BuildCanteen()
- {
- if (!this.hasCanteen)
- {
- this.hasCanteen = true;
- Console.WriteLine("Была построенна столовая");
- }
- else
- {
- Console.WriteLine("Столовая уже есть");
- }
- }
- public void AddPupil()
- {
- this.CountOfStudents++;
- }
- public void AddPupil(int count)
- {
- this.CountOfStudents += count;
- }
- public void ChangeSchoolName(string name)
- {
- this.UniversityName = name;
- }
- public void Info()
- {
- Console.WriteLine($"Название университета: {this.UniversityName}\n" +
- $"Директор университета: {this.RectorName}\n" +
- $"Количество учащихся: {this.CountOfStudents}\n" +
- $"Количество наград: {this.awards.Count}\n" +
- $"Наличие столовой: {this.hasCanteen}");
- }
- }
- public class College
- {
- int CountOfStudents;
- string UniversityName, director;
- List<string> awards;
- bool hasCanteen;
- public College()
- {
- CountOfStudents = 0;
- UniversityName = "some college";
- director = "some director";
- awards = new List<string>();
- hasCanteen = false;
- }
- public College(string schoolName, string directorName, int countOfPupils, bool hasCanteen)
- {
- this.UniversityName = schoolName;
- this.director = directorName;
- this.CountOfStudents = countOfPupils;
- this.hasCanteen = hasCanteen;
- this.awards = new List<string>();
- }
- public void NewAward(string newAward)
- {
- this.awards.Add(newAward);
- }
- public void GetAwards()
- {
- Console.WriteLine("Awards List:");
- for (int i = 0; i < this.awards.Count; i++)
- {
- Console.WriteLine(this.awards[i]);
- }
- }
- public void ChangeDirector(string newDirectorName)
- {
- this.director = newDirectorName;
- }
- public void BuildCanteen()
- {
- if (!this.hasCanteen)
- {
- this.hasCanteen = true;
- Console.WriteLine("Была построенна столовая");
- }
- else
- {
- Console.WriteLine("Столовая уже есть");
- }
- }
- public void AddPupil()
- {
- this.CountOfStudents++;
- }
- public void AddPupil(int count)
- {
- this.CountOfStudents += count;
- }
- public void ChangeSchoolName(string name)
- {
- this.UniversityName = name;
- }
- public void Info()
- {
- Console.WriteLine($"Название колледжа: {this.UniversityName}\n" +
- $"Директор колледжа: {this.director}\n" +
- $"Количество учащихся: {this.CountOfStudents}\n" +
- $"Количество наград: {this.awards.Count}\n" +
- $"Наличие столовой: {this.hasCanteen}");
- }
- }
- public class SpecSchool
- {
- int CountOfStudents;
- string SpecSchoolName, director;
- List<string> awards;
- bool hasCanteen;
- public SpecSchool()
- {
- CountOfStudents = 0;
- SpecSchoolName = "some specSchool";
- director = "some director";
- awards = new List<string>();
- hasCanteen = false;
- }
- public SpecSchool(string schoolName, string directorName, int countOfPupils, bool hasCanteen)
- {
- this.SpecSchoolName = schoolName;
- this.director = directorName;
- this.CountOfStudents = countOfPupils;
- this.hasCanteen = hasCanteen;
- this.awards = new List<string>();
- }
- public void NewAward(string newAward)
- {
- this.awards.Add(newAward);
- }
- public void GetAwards()
- {
- Console.WriteLine("Awards List:");
- for (int i = 0; i < this.awards.Count; i++)
- {
- Console.WriteLine(this.awards[i]);
- }
- }
- public void ChangeDirector(string newDirectorName)
- {
- this.director = newDirectorName;
- }
- public void BuildCanteen()
- {
- if (!this.hasCanteen)
- {
- this.hasCanteen = true;
- Console.WriteLine("Была построенна столовая");
- }
- else
- {
- Console.WriteLine("Столовая уже есть");
- }
- }
- public void AddPupil()
- {
- this.CountOfStudents++;
- }
- public void AddPupil(int count)
- {
- this.CountOfStudents += count;
- }
- public void ChangeSchoolName(string name)
- {
- this.SpecSchoolName = name;
- }
- public void Info()
- {
- Console.WriteLine($"Название училища: {this.SpecSchoolName}\n" +
- $"Директор училища: {this.director}\n" +
- $"Количество учащихся: {this.CountOfStudents}\n" +
- $"Количество наград: {this.awards.Count}\n" +
- $"Наличие столовой: {this.hasCanteen}");
- }
- }
- public class Office
- {
- string officeName;
- int countOfOrders, countOfWorkers;
- List<string> assortiment;
- bool hasFood;
- public Office()
- {
- this.officeName = "some Office";
- this.hasFood = false;
- this.countOfOrders = 0;
- this.countOfOrders = 0;
- this.assortiment = new List<string>();
- }
- public Office(string officeName, int countOfWorkers, bool hasFood)
- {
- this.officeName = officeName;
- this.countOfWorkers = countOfWorkers;
- this.hasFood = hasFood;
- this.assortiment = new List<string>();
- this.countOfOrders = 0;
- }
- public void GetOrder(int count)
- {
- this.countOfOrders += count;
- }
- public void ServeOrders()
- {
- Console.WriteLine($"Заказов в очереди: {this.countOfOrders}");
- this.countOfOrders -= this.countOfWorkers;
- if (countOfOrders <= 0)
- {
- Console.WriteLine("Все заказы выполенны");
- this.countOfOrders = 0;
- }
- else
- {
- Console.WriteLine($"Осталось заказов: {this.countOfOrders}");
- }
- }
- public void AddAssortiment(string someProduct, bool isFood)
- {
- this.assortiment.Add(someProduct);
- if (!this.hasFood && isFood)
- {
- this.hasFood = true;
- }
- }
- public void PrintAssortiment()
- {
- Console.WriteLine("Assortiment:");
- if (this.assortiment.Count == 0)
- {
- Console.WriteLine("Empty");
- }
- for (int i = 0; i < this.assortiment.Count; i++)
- {
- Console.WriteLine(this.assortiment[i]);
- }
- }
- public void HireMan(int count)
- {
- this.countOfWorkers += count;
- }
- public void HireMan()
- {
- this.countOfWorkers++;
- }
- public void Info()
- {
- Console.WriteLine($"Название канцелярской: {this.officeName}\n" +
- $"Количество работников: {this.countOfWorkers}\n" +
- $"Товаров в ассортименте: {this.assortiment.Count}\n" +
- $"Активных заказов: {this.countOfOrders}\n" +
- $"Еда в ассортименте: {this.hasFood}");
- }
- }
- delegate void voidDelegateNoParams();
- delegate void voidDelegateStringParams(string source);
- static void Main()
- {
- School school = new("Школа", "Абрамов", 10, false);
- voidDelegateNoParams delegate1 = new voidDelegateNoParams(school.GetAwards);
- delegate1 += school.BuildCanteen;
- delegate1 += school.BuildCanteen;
- delegate1 += school.Info;
- school.NewAward("молодцы");
- //!!!
- delegate1.Invoke();
- //!!!
- Console.WriteLine();
- University university = new("БГТУ", "Наумов", 200, true);
- voidDelegateNoParams delegate2 = new voidDelegateNoParams(university.GetAwards);
- delegate2 += university.Info;
- university.NewAward("Лучший университет");
- university.NewAward("Самый лучий университет");
- university.NewAward("Ну правда самый лучший университет");
- //!!!
- delegate2.Invoke();
- //!!!
- Console.WriteLine();
- College mrk = new("Минский радиотехнический колледж", "кто-то новый", 1000, true);
- mrk.NewAward("молодцы");
- mrk.GetAwards();
- Console.WriteLine();
- mrk.BuildCanteen();
- mrk.Info();
- Console.WriteLine();
- SpecSchool PTU = new("Училище имени ______", "Иванов", 2, false);
- PTU.NewAward("молодцы");
- PTU.GetAwards();
- Console.WriteLine();
- PTU.Info();
- Console.WriteLine();
- Office office = new Office("Печатная", 4, false);
- office.AddAssortiment("Апельсинки", true);
- office.HireMan();
- office.GetOrder(3);
- office.ServeOrders();
- office.PrintAssortiment();
- office.Info();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment