Advertisement
Fle2x

5.4

Jun 20th, 2021
726
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Hr
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             List<string> fullName = new List<string>() { "Беляев Матвей Артёмович", "Блажевич Игорь Юрьевич", "Валиева Руфина Рафаэлевна" };
  11.             List<string> position = new List<string>() { "Event-менеджер", "SEO-оптимизатор", "SMM-менеджер" };
  12.             bool exit = false;
  13.  
  14.             while (!exit)
  15.             {
  16.                 Console.WriteLine("Выберите пункт меню:\n1.Добавить досье\n2.Вывести все досье\n3.Удалить досье\n4.Выход", '-');
  17.                 int menu = Convert.ToInt32(Console.ReadLine());
  18.                 Console.WriteLine();
  19.                 switch (menu)
  20.                 {
  21.                     case 1:
  22.                         AddInformation(ref fullName, ref position);
  23.                         break;
  24.                     case 2:
  25.                         Console.WriteLine("Все досье: ");
  26.                         PrintFullNameAndPosition(ref fullName, ref position);
  27.                         break;
  28.                     case 3:
  29.                         RemoveFullNameAndPosition(ref fullName, ref position);
  30.                         break;
  31.                     case 4:
  32.                         exit = true;
  33.                         break;
  34.                     default:
  35.                         Console.WriteLine("Нет такого пункта меню.");
  36.                         break;
  37.                 }
  38.             }
  39.             Console.ReadKey();
  40.         }
  41.  
  42.         static void AddInformation(ref List<string> fullName, ref List<string> position)
  43.         {
  44.             Console.WriteLine("Введите ФИО: ");
  45.             string enterFullName = Console.ReadLine();
  46.             Console.WriteLine("Введите должность: ");
  47.             string enterPosition = Console.ReadLine();
  48.             fullName.Add(enterFullName);
  49.             position.Add(enterPosition);
  50.             Console.WriteLine();
  51.         }
  52.  
  53.         static void RemoveFullNameAndPosition(ref List<string> fullName, ref List<string> position)
  54.         {
  55.             if (fullName.Count == 0)
  56.             {
  57.                 Console.WriteLine("Нет записей.");
  58.             }
  59.             else
  60.             {
  61.                 Console.WriteLine("Выберите досье,которое хотите удалить: ");
  62.                 int id = Convert.ToInt32(Console.ReadLine());
  63.                 Console.WriteLine();
  64.                 if (fullName.Count- 1 >= id)
  65.                 {
  66.                     fullName.RemoveAt(id);
  67.                     position.RemoveAt(id);
  68.                     Console.WriteLine($"Вы удалили досье под номером - {id}");
  69.                 }
  70.                 else
  71.                 {
  72.                     Console.WriteLine($"Досье под номером {id} не существует.");
  73.                 }
  74.             }
  75.             Console.WriteLine();
  76.         }
  77.  
  78.         static void PrintFullNameAndPosition(ref List<string> fullName, ref List<string> position)
  79.         {
  80.             if (fullName.Count==0)
  81.             {
  82.                 Console.WriteLine("Нет записей.");
  83.             }
  84.             else
  85.             {
  86.                 for (int i = 0; i < fullName.Count; i++)
  87.                 {
  88.                     Console.WriteLine($"{i}. {fullName[i]} - {position[i]}");
  89.                 }
  90.             }
  91.             Console.WriteLine();
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement