Advertisement
LeRoY_Go

Untitled

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