LeRoY_Go

Untitled

Feb 4th, 2022
866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.78 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 = false;
  11.             List<string> fullNames = new List<string> { "Гришин Аверьян Вячеславович", "Гришин Аверьян Вячеславович", "Гурьев Ермак Альвианович", "Уварова Инна Оскаровна", "Комиссарова Нора Лукьяновна", "Гордеева Герда Еремеевна" };
  12.             List<string> positionsEmployee = new List<string> { "Специалист", "Старшый специалист", "Специалист", "Старшый специалист", "Руководитель группы", "Начальник отдела" };
  13.  
  14.             while (isExit == false)
  15.             {
  16.                 Console.WriteLine("1 - добавить досье\n2 - вывести все досье\n3 - удалить досье\n4 - поиск досье\n5 - выход");
  17.                 Console.Write("Введите команду: ");
  18.                 string userInput = Console.ReadLine();
  19.  
  20.                 switch (userInput)
  21.                 {
  22.                     case "1":
  23.                         AddDossier(fullNames, positionsEmployee);
  24.                         break;
  25.                     case "2":
  26.                         ShowDossier(fullNames, positionsEmployee);
  27.                         break;
  28.                     case "3":
  29.                         SelectingDossierDelete(fullNames, positionsEmployee);
  30.                         break;
  31.                     case "4":
  32.                         SearchDossier(fullNames, positionsEmployee);
  33.                         break;
  34.                     case "5":
  35.                         isExit = true;
  36.                         break;
  37.                 }
  38.  
  39.                 Console.Write("Нажмите Enter чтобы вернуться в меню.");
  40.                 Console.ReadLine();
  41.             }
  42.         }
  43.  
  44.         static void AddDossier(List<string> fullName, 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.             fullName.Add(userInputFullName);
  54.             Console.Write("Введите должность: ");
  55.             string userInputPost = Console.ReadLine();
  56.             positionEmployee.Add(userInputPost);
  57.             Console.WriteLine("Новое досье: " + userInputFullName + " - " + userInputPost);
  58.         }
  59.  
  60.         static void ShowDossier(List<string> fullName, List<string> post)
  61.         {
  62.             for (int i = 0; i < fullName.Count; i++)
  63.             {
  64.                 Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
  65.             }
  66.         }
  67.  
  68.         static void SelectingDossierDelete(List<string> fullNames, List<string> positionsEmployee)
  69.         {
  70.             Console.Write("Введите номер досье: ");
  71.             bool isNumber = int.TryParse(Console.ReadLine(), out int number);
  72.             int index = number - 1;
  73.  
  74.             if (isNumber == true && index >= 0 && index < fullNames.Count)
  75.             {
  76.                 DeleteDossier(fullNames, index);
  77.                 DeleteDossier(positionsEmployee, index);
  78.                 Console.WriteLine("Досье №" + (index + 1) + " удаленно.");
  79.             }
  80.             else
  81.             {
  82.                 Console.WriteLine("Досье с таким номером нет.");
  83.             }
  84.         }
  85.  
  86.         static void DeleteDossier(List<string> array, int index)
  87.         {
  88.             array.RemoveAt(index);
  89.         }
  90.  
  91.         static void SearchDossier(List<string> fullName, List<string> post)
  92.         {
  93.             Console.Write("Введите № досье сотрудника: ");
  94.             bool isNumber = int.TryParse(Console.ReadLine(), out int number);
  95.             int numberDossier = number - 1;
  96.  
  97.             if (isNumber == true && numberDossier > 0 && numberDossier <= fullName.Count)
  98.             {
  99.                 Console.WriteLine("Досье сотрудника: №" + (numberDossier + 1) + " " + fullName[numberDossier] + " - " + post[numberDossier]);
  100.             }
  101.             else
  102.             {
  103.                 Console.WriteLine("Досье с таким номером нет.");
  104.             }
  105.         }
  106.     }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment