Advertisement
LeRoY_Go

Untitled

Feb 4th, 2022
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.93 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.                         PreparingDossier(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 PreparingDossier(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.             AddDossier(fullName, userInputFullName);
  54.             Console.Write("Введите должность: ");
  55.             string userInputPost = Console.ReadLine();
  56.             AddDossier(positionEmployee, userInputPost);
  57.             Console.WriteLine("Новое досье: " + userInputFullName + " - " + userInputPost);
  58.         }
  59.  
  60.         static void AddDossier(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(List<string> fullNames, List<string> positionsEmployee)
  74.         {
  75.             Console.Write("Введите номер досье: ");
  76.             bool isNumber = int.TryParse(Console.ReadLine(), out int number);
  77.             int index = number - 1;
  78.  
  79.             if (isNumber == true && index >= 0 && index < fullNames.Count)
  80.             {
  81.                 DeleteDossier(fullNames, index);
  82.                 DeleteDossier(positionsEmployee, index);
  83.                 Console.WriteLine("Досье №" + (index + 1) + " удаленно.");
  84.             }
  85.             else
  86.             {
  87.                 Console.WriteLine("Досье с таким номером нет.");
  88.             }
  89.         }
  90.  
  91.         static void DeleteDossier(List<string> array, int index)
  92.         {
  93.             array.RemoveAt(index);
  94.         }
  95.  
  96.         static void SearchDossier(List<string> fullName, List<string> post)
  97.         {
  98.             Console.Write("Введите № досье сотрудника: ");
  99.             bool isNumber = int.TryParse(Console.ReadLine(), out int number);
  100.             int numberDossier = number - 1;
  101.  
  102.             if (isNumber == true && numberDossier > 0 && numberDossier <= fullName.Count)
  103.             {
  104.                 Console.WriteLine("Досье сотрудника: №" + (numberDossier + 1) + " " + fullName[numberDossier] + " - " + post[numberDossier]);
  105.             }
  106.             else
  107.             {
  108.                 Console.WriteLine("Досье с таким номером нет.");
  109.             }
  110.         }
  111.     }
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement