Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace egor
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool isOpen = true;
- Dictionary<int, string> dossier = new Dictionary<int, string>();
- int quantityDossiers = 1;
- string userInput;
- while (isOpen == true)
- {
- Console.WriteLine("1 - Добавить досье.\n2 - Вывести все досье.\n3 - Удалить досье.\n4 - Выход");
- Console.WriteLine("Введите номер команды.");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "1":
- Console.Clear();
- Console.Write("Введите ФИО и должность: ");
- userInput = Console.ReadLine();
- IncreaseArray(dossier, userInput, ref quantityDossiers);
- break;
- case "2":
- Console.Clear();
- WithdrawAllDossiers(dossier, quantityDossiers);
- break;
- case "3":
- Console.Clear();
- WithdrawAllDossiers(dossier, quantityDossiers);
- Console.WriteLine("Ввдите номер досье которое хотите удолить");
- userInput = Console.ReadLine();
- DeletionDossier(dossier, userInput);
- break;
- case "4":
- isOpen = false;
- break;
- }
- }
- }
- static void IncreaseArray(Dictionary<int, string> dossier, string userInput, ref int quantityDossiers)
- {
- dossier.Add(quantityDossiers, userInput);
- quantityDossiers++;
- }
- static void WithdrawAllDossiers(Dictionary<int, string> dossier, int quantityDossiers)
- {
- foreach(var oneDossier in dossier)
- {
- Console.Write(oneDossier.Key + ". " + oneDossier.Value);
- if (quantityDossiers > 2)
- {
- Console.Write("-");
- }
- Console.WriteLine();
- }
- }
- static void DeletionDossier(Dictionary<int, string> dossier, string userInput)
- {
- int dossierNumber;
- bool result = int.TryParse(userInput, out dossierNumber);
- if (result == true)
- {
- dossier.Remove(dossierNumber);
- }
- else
- {
- Console.WriteLine("ошибка удаления");
- Console.WriteLine("введите число");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment