Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- //using System.Text;
- //using System.Threading.Tasks;
- //using System.Linq;
- //using System.IO;
- using System.Collections.Generic; //пространство имен для List <>
- namespace bazaRabochihTheBEST
- {
- class Program
- {
- public static List<object> otdely = new List<object>();
- public static List<object> bosses = new List<object>();
- public static List<object> rabotniki = new List<object>();
- public static int nomer_otdela;
- public struct OTDEL
- {
- public string name;
- public OTDEL(string name)
- {
- this.name = name;
- }
- }
- public struct BOSS
- {
- public string name;
- public int age;
- public long salary;
- public object name_otd;
- //МАССИВ(ЛИСТ/СПИСОК) ИЗ СТРУКТУР РАБОТНИКОВ
- //В КАКОМ ОТДЕЛЕ
- public BOSS(string name, int age, long salary, object name_otd)
- {
- this.name = name;
- this.age = age;
- this.salary = salary;
- this.name_otd = name_otd;
- }
- }
- public struct RABOTNIK
- {
- public string name;
- public int age;
- public long salary;
- public object name_otd;
- public object name_boss;
- public RABOTNIK (string name, int age, long salary, object name_otd, object name_boss)
- {
- this.name = name;
- this.age = age;
- this.salary = salary;
- this.name_otd = name_otd;
- this.name_boss = name_boss;
- }
- //КТО БОСС
- //В КАКОМ ОТДЕЛЕ
- }
- public static void whatCreate()
- {
- int x = 1;
- while (x != 0)
- {
- Console.WriteLine("Что вы хотите создать? (введите выбранный пункт) \n 1. Отдел \n 2. Начальника \n 3. Работника \n Введите 0, если хотите выйти из программы.");
- int a = Convert.ToInt32(Console.ReadLine());
- x = a;
- switch (a)
- {
- case 1:
- Console.WriteLine("Создание отдела!");
- genOtdel();
- break;
- case 2:
- Console.WriteLine("Создание начальника!");
- genBoss();
- break;
- case 3:
- Console.WriteLine("Создание работника!");
- //genRabotnik();
- break;
- case 0:
- break;
- }
- }
- }
- public static string write(string x)
- {
- Console.Write($"{x} : ");
- return Console.ReadLine();
- }
- public static void genOtdel()
- {
- OTDEL otd = new OTDEL();
- otd.name = write("Название отдела");
- Console.WriteLine(" ");
- otdely.Add(otd.name);
- }
- /* public static void vKakoiOtdelBossa (int a)
- {
- switch (a)
- {
- case 0:
- genOtdel();
- break;
- }
- }*/
- public static void kudaOpredelitBossa()
- {
- Console.WriteLine("Перед тем, как создать босса, необходимо выбрать отдел, в котором он будет. Список отделов:");
- for(int i = 0; i < otdely.Count; i++)
- {
- Console.WriteLine($"{i+1}. {otdely[i]} ");
- }
- Console.WriteLine("Введите номер отдела, в который вы ходите определить босса. Введите 0, если хотите создать новый отдел.");
- int a = Convert.ToInt32(Console.ReadLine());
- if (a != 0)
- {
- nomer_otdela = a - 1;
- }
- else
- {
- nomer_otdela = otdely.Count;
- genOtdel();
- }
- }
- public static void genBoss()
- {
- kudaOpredelitBossa();
- BOSS boss = new BOSS();
- boss.name = write("Имя босса");
- boss.age = Convert.ToInt32(write("Возраст босса"));
- boss.salary = Convert.ToInt64(write("Зарплата босса"));
- boss.name_otd = otdely[nomer_otdela];
- Console.WriteLine($"Отдел босса: {boss.name_otd}");
- Console.WriteLine(" ");
- bosses.Add(boss);
- // otdely[a].Add(boss);
- }
- public static void genOtdelANDBoss()
- {
- int index_otd = otdely.Count;
- genOtdel();
- //int index_bosses = bosses.Count;
- BOSS boss = new BOSS();
- boss.name = write("Имя босса");
- boss.age = Convert.ToInt32(write("Возраст босса"));
- boss.salary = Convert.ToInt64(write("Зарплата босса"));
- boss.name_otd = otdely[index_otd];
- Console.WriteLine($"Отдел босса: {boss.name_otd}");
- Console.WriteLine(" ");
- bosses.Add(boss);
- }
- public static void genRabotnik()
- {
- Console.WriteLine("Прежде чем создать работника, необходимо выбрать отдел, в котором он будет числиться. Список отделов: ");
- for (int i = 0; i < otdely.Count; i++)
- {
- Console.WriteLine($"{i + 1}. {otdely[i]} ");
- }
- Console.WriteLine("Введите номер выбранного отдела. Если хоите создать новый отдел - введите 0.");
- int nomer_otdela2 = Convert.ToInt32(Console.ReadLine());
- if (nomer_otdela2 == 0)
- {
- RABOTNIK rab = new RABOTNIK();
- int index_otd = otdely.Count;
- // int index_bosses = bosses.Count;
- genOtdelANDBoss();
- rab.name = write("Имя работника");
- rab.age = Convert.ToInt32(write("Возраст работника"));
- rab.salary = Convert.ToInt64(write("Зарплата работника"));
- rab.name_otd = otdely[index_otd];
- }
- }
- static void Main(string[] args)
- {
- /*Console.WriteLine("Что вы хотите создать? (введите выбранный пункт) \n 1. Отдел \n 2. Начальника \n 3. Работника");
- int a = Convert.ToInt32(Console.ReadLine());*/
- whatCreate();
- /*if (a==0)
- {
- Console.WriteLine("Вы вышли из программы!!!");
- return 0;
- }
- else
- {
- whatCreate(a);
- }*/
- }
- // otdely.AddRange(OTDEL);
- /* foreach(object i in otdely)
- {
- Console.WriteLine(i); //первый прогон: i=0, но здесь при foreach в первом прогоне i=otdely[i], т.е. самому значению элемента
- }
- */
- // Console.WriteLine("Hello World!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement