Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- const string AddDossiser = "AddDossiser";
- const string ShowAllDossiser = "ShowAllDossiser";
- const string RemoveDossiser = "RemoveDossiser";
- const string Exit = "Exit";
- Dictionary<string, string> dossiers = new Dictionary<string, string>();
- bool isExit = true;
- while (isExit)
- {
- Console.ResetColor();
- Console.WriteLine("1) Добавить досье - \'AddDossiser\' \n" +
- "2) Вывести все досье - \'ShowAllDossiser\' \n" +
- "3) Удалить досье - \'RemoveDossiser\' \n" +
- "4) Выход - \'Exit\' ");
- string input = Console.ReadLine();
- Console.ForegroundColor = ConsoleColor.Green;
- switch (input)
- {
- case AddDossiser:
- AddDossier(dossiers);
- break;
- case ShowAllDossiser:
- ShowAllDossier(dossiers);
- break;
- case RemoveDossiser:
- RemoveDossier(dossiers);
- break;
- case Exit:
- isExit = false;
- break;
- default:
- Console.WriteLine("Неверный код");
- break;
- }
- Console.WriteLine("");
- }
- Console.ReadLine();
- }
- private static void AddDossier(Dictionary<string, string> dossiers)
- {
- Console.WriteLine("Введите ФИО.");
- string fullname = Console.ReadLine();
- if (dossiers.Keys.Contains(fullname))
- {
- Console.WriteLine("Такой сотрудник уже есть в базе");
- }
- else
- {
- Console.WriteLine("Введите Должность");
- string post = Console.ReadLine();
- dossiers.Add(fullname, post);
- Console.WriteLine("Успешно!");
- }
- }
- private static void ShowAllDossier(Dictionary<string,string> dossiers)
- {
- foreach (var item in dossiers)
- {
- Console.WriteLine($"{item.Key} - {item.Value}");
- }
- }
- private static void RemoveDossier(Dictionary<string, string> dossiers)
- {
- Console.WriteLine("Введите ФИО сотрудника");
- string input = Console.ReadLine();
- if (dossiers.Keys.Contains(input))
- {
- dossiers.Remove(input);
- Console.WriteLine("Успешно!");
- return;
- }
- Console.WriteLine("Неверная ФИО");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement