Advertisement
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 personnelRecords
- {
- class Program
- {
- static void Main(string[] args)
- {
- bool isRun = true;
- Dictionary<string, string> files = new Dictionary<string, string>(0);
- while (isRun)
- {
- Console.WriteLine("[1] - добавить досье\n[2] - вывести все досье\n[3] - удалить досье\n[4] - выход");
- Console.Write("Ввод: ");
- switch (Console.ReadLine())
- {
- case "1":
- AddFile(files);
- break;
- case "2":
- PrintFiles(files);
- break;
- case "3":
- DeleteFile(files);
- break;
- case "4":
- isRun = false;
- break;
- }
- }
- }
- static void AddFile(Dictionary<string, string> files)
- {
- Console.Write("Введите ФИО: ");
- string fullName = Console.ReadLine();
- if(files.ContainsKey(fullName))
- {
- Console.WriteLine("Ошибка! Сотрудник существует.");
- return;
- }
- Console.Write("Введите должность: ");
- string position = Console.ReadLine();
- files.Add(fullName, position);
- }
- static void PrintFiles(Dictionary<string, string> files)
- {
- if (files.Count == 0)
- {
- Console.WriteLine("Пусто!");
- return;
- }
- foreach (var file in files)
- {
- Console.WriteLine($"{file.Key} - {file.Value}");
- }
- }
- static void DeleteFile(Dictionary<string, string> files)
- {
- string userInput;
- if (files.Count == 0)
- {
- Console.WriteLine("Пусто!");
- return;
- }
- Console.Write("Введите ФИО: ");
- userInput = Console.ReadLine();
- if (files.ContainsKey(userInput) == true)
- {
- Console.WriteLine("Удаляем...");
- files.Remove(userInput);
- }
- else
- {
- Console.WriteLine("Такого досье нет!");
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement