Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- namespace HomeWorks
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> posts = new List<string>();
- List<string> initials = new List<string>();
- string userInput = "";
- while (userInput != "exit")
- {
- Console.Clear();
- Console.WriteLine("1) add - Добавить досье\n2) output_all - Вывести все досье\n" +
- "3) delete - удалить досье\n4) exit - Выход из программы\n");
- Console.Write("Введите команду: ");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "add":
- addDossier(ref posts, ref initials);
- break;
- case "output_all":
- outputAll(posts, initials);
- break;
- case "delete":
- outputAll(posts, initials);
- deleteDossier(posts, initials);
- break;
- case "exit":
- Console.Write("Все досье будут удалены!\nНажмите любую клавишу для выхода...");
- break;
- default:
- Console.Write("Такой команды нет!\nНажмите любую клавишу для продолжения...");
- break;
- }
- Console.ReadKey();
- }
- }
- static void addDossier(ref List<string> posts, ref List<string> initials)
- {
- Console.Write("Введите должность: ");
- string userInputPost = Console.ReadLine();
- posts.Add(userInputPost);
- Console.Write("Введите ФИО: ");
- string userInputInitials = Console.ReadLine();
- initials.Add(userInputInitials);
- Console.Write("Досье успешно добавлено!\nНажмите любую клавишу для продолжения...");
- }
- static void outputAll(List<string> posts, List<string> initials)
- {
- int dossierNumber;
- for (int i = 0; i < posts.Count; i++)
- {
- dossierNumber = i + 1;
- Console.WriteLine($"{dossierNumber}. {posts[i]} - {initials[i]}");
- }
- }
- static void deleteDossier(List<string> posts, List<string> initials)
- {
- Console.Write("Введите номер досье, для его удаления: ");
- int userInput = Convert.ToInt32(Console.ReadLine());
- int dossierIndex = userInput - 1;
- if (userInput > 0 && userInput <= posts.Count)
- {
- initials.RemoveAt(dossierIndex);
- posts.RemoveAt(dossierIndex);
- Console.Write("Досье успешно удалено!");
- }
- else
- {
- Console.Write("Такого досье нет!");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment