Advertisement
Vlad_Savitskiy

Dossiers 2

Jun 28th, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace CSLightFirst
  5. {
  6.     class Program
  7.     {
  8.         public static void Main()
  9.         {
  10.             Dictionary<string, string> dossiers = new Dictionary<string, string>();
  11.             bool isExit = false;
  12.  
  13.             Console.WriteLine("Добро пожаловать в базу досье.\nДоступные действия:\n");
  14.  
  15.             while (!isExit)
  16.                 switch (GetUserInputInMainMenu())
  17.                 {
  18.                     case "1":
  19.                         Console.Clear();
  20.                         dossiers.Add(GetUserInput("Введите полное имя: "), GetUserInput("Введите должность: "));
  21.                         break;
  22.                     case "2":
  23.                         ShowAllDossiers(dossiers);
  24.                         break;
  25.                     case "3":
  26.                         dossiers.Remove(GetUserInput("Введите ФИО удаляемого досье: "));
  27.                         break;
  28.                     case "4":
  29.                         isExit = true;
  30.                         break;
  31.                     default:
  32.                         Console.Clear();
  33.                         Console.WriteLine("Неверная команда, попробуйте ещё раз.");
  34.                         break;
  35.                 }
  36.         }
  37.  
  38.         private static string GetUserInputInMainMenu()
  39.         {
  40.             Console.WriteLine("\n1 - Добавить досье\n" +
  41.                               "2 - Вывести все досье\n" +
  42.                               "3 - Удалить досье\n" +
  43.                               "4 - Выход из программы\n");
  44.             Console.Write("Что бы Вы хотели сделать? ");
  45.             return Console.ReadLine();
  46.         }
  47.  
  48.         private static string GetUserInput(string lineForUser)
  49.         {
  50.             Console.Write(lineForUser);
  51.             return Console.ReadLine();
  52.         }
  53.  
  54.         private static void ShowAllDossiers(Dictionary<string, string> dossiers)
  55.         {
  56.             Console.Clear();
  57.             Console.WriteLine("Полный список досье:\n" +
  58.                               " (№ : Полное имя - Должность)\n");
  59.  
  60.             int count = 1;
  61.             foreach (KeyValuePair<string, string> dossier in dossiers)
  62.             {
  63.                 Console.WriteLine($"  {count} : {dossier.Key} - {dossier.Value}");
  64.                 count++;
  65.             }
  66.  
  67.             Console.ReadKey();
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement