Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace CSharpLight_HomeWork_CardFilePro
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, string> cardFile = new Dictionary<string, string>();
- string userInput;
- bool working = true;
- while (working)
- {
- WriteCommands();
- userInput = Console.ReadLine();
- Console.Clear();
- switch (userInput)
- {
- case "1":
- AddFile(cardFile);
- Console.Clear();
- break;
- case "2":
- ShowFiles(cardFile);
- break;
- case "3":
- DeleteFile(cardFile);
- Console.Clear();
- break;
- case "4":
- Console.WriteLine("До свидания.");
- working = false;
- break;
- default:
- Console.WriteLine("Некорректный номер команды.");
- break;
- }
- }
- Console.ReadKey();
- }
- static void AddFile(Dictionary<string, string> cardFile)
- {
- string name;
- string position;
- Console.Write("Введите ФИО: ");
- name = Console.ReadLine();
- Console.Write("Введите должность: ");
- position = Console.ReadLine();
- cardFile.Add(name, position);
- }
- static void ShowFiles(Dictionary<string, string> cardFile)
- {
- foreach (var file in cardFile)
- {
- Console.WriteLine($"{file.Key} - {file.Value}");
- }
- }
- static void DeleteFile(Dictionary<string, string> cardFile)
- {
- Console.WriteLine("Введите ФИО человека, которого хотите удалить из досье.");
- string userValue = Console.ReadLine();
- cardFile.Remove(userValue);
- }
- static void WriteCommands()
- {
- Console.WriteLine("1. Добавить досье.");
- Console.WriteLine("2. Вывести все досье.");
- Console.WriteLine("3. Удалить досье.");
- Console.WriteLine("4. Выход.");
- Console.Write("Введите номер команды: ");
- }
- }
- }
Add Comment
Please, Sign In to add comment