Advertisement
LeRoY_Go

Untitled

Jan 31st, 2022
1,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.12 KB | None | 0 0
  1. using System;
  2.  
  3. namespace C_Sharp_Junior
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             bool isExit = true;
  10.             string[] fullName = { "Гришин Аверьян Вячеславович", "Гурьев Ермак Альвианович", "Уварова Инна Оскаровна", "Комиссарова Нора Лукьяновна", "Гордеева Герда Еремеевна" };
  11.             string[] positionEmployee = { "Специалист", "Специалист", "Старшый специалист", "Руководитель группы", "Начальник отдела" };
  12.             while (isExit == true)
  13.             {
  14.                 Console.WriteLine("1 - добавить досье\n2 - вывести все досье\n3 - удалить досье\n4 - поиск по фамилии\n5 - выход");
  15.                 Console.Write("Введите команду: ");
  16.                 string userInput = Console.ReadLine();
  17.                 Console.Clear();
  18.                 switch (userInput)
  19.                 {
  20.                     case "1":
  21.                         Console.Write("Введите фамилию: ");
  22.                         string userInputSurname = Console.ReadLine();
  23.                         Console.Write("Введите имя: ");
  24.                         string userInputName = Console.ReadLine();
  25.                         Console.Write("Введите отчество: ");
  26.                         string userInputPatronymic = Console.ReadLine();
  27.                         string userInputFullName = userInputSurname + " " + userInputName + " " + userInputPatronymic;
  28.                         AddDossier(ref fullName, userInputFullName);
  29.  
  30.                         Console.Write("Введите должность: ");
  31.                         string userInputPost = Console.ReadLine();
  32.                         AddDossier(ref positionEmployee, userInputPost);
  33.                         Console.WriteLine("Новое досье: " + userInputFullName + " - " + userInputPost);
  34.                         break;
  35.                     case "2":
  36.                         ShowDossier(fullName, positionEmployee);
  37.                         break;
  38.                     case "3":
  39.                         Console.Write("Введите номер досье: ");
  40.                         int index = Convert.ToInt32(Console.ReadLine()) - 1;
  41.                         fullName = DeleteDossier(fullName, index);
  42.                         positionEmployee = DeleteDossier(positionEmployee, index);
  43.                         Console.WriteLine("Досье №" + (index + 1) + " удаленно.");
  44.                         break;
  45.                     case "4":
  46.                         SearchDossier(fullName, positionEmployee, out userInputFullName);
  47.                         break;
  48.                     case "5":
  49.                         isExit = false;
  50.                         break;
  51.                 }
  52.                 Console.Write("Нажмите Enter чтобы вернуться в меню.");
  53.                 Console.ReadLine();
  54.                 Console.Clear();
  55.             }
  56.             Environment.Exit(50);
  57.         }
  58.  
  59.         static void AddDossier(ref string[] Arrey, string userInput)
  60.         {
  61.             string[] tempArrey = new string[Arrey.Length + 1];
  62.  
  63.             tempArrey[tempArrey.Length - 1] = userInput;
  64.  
  65.             for (int i = 0; i < Arrey.Length; i++)
  66.             {
  67.                 tempArrey[i] = Arrey[i];
  68.             }
  69.             Arrey = tempArrey;
  70.         }
  71.  
  72.         static void ShowDossier(string[] fullName, string[] post)
  73.         {
  74.             for (int i = 0; i < fullName.Length; i++)
  75.             {
  76.                 Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
  77.             }
  78.         }
  79.  
  80.         static string[] DeleteDossier(string[] Arrey, int index)
  81.         {
  82.             string[] tempArrey = new string[Arrey.Length - 1];
  83.             for (int i = 0; i < index; i++)
  84.             {
  85.                 tempArrey[i] = Arrey[i];
  86.             }
  87.             for (int i = index; i < tempArrey.Length; i++)
  88.             {
  89.                 tempArrey[i] = Arrey[i + 1];
  90.             }
  91.             return tempArrey;
  92.         }
  93.  
  94.         static void SearchDossier(string[] fullName, string[] post, out string userInputFullName)
  95.         {
  96.             bool employeeFound = false;
  97.             Console.Write("Введите ФИО сотрудника через пробел: ");
  98.             userInputFullName = Console.ReadLine();
  99.             for (int i = 0; i < fullName.Length; i++)
  100.             {
  101.                 if (userInputFullName.ToLower() == fullName[i].ToLower())
  102.                 {
  103.                     Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
  104.                     employeeFound = true;
  105.                     break;
  106.                 }
  107.             }
  108.             if (employeeFound == false)
  109.             {
  110.                 Console.WriteLine("Сотрудника с такой ФИО нету.");
  111.             }
  112.         }
  113.     }
  114. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement