Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp3
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] fullName = { "Гришин Аверьян Вячеславович", "Гурьев Ермак Альвианович", "Уварова Инна Оскаровна", "Комиссарова Нора Лукьяновна", "Гордеева Герда Еремеевна" };
- string[] post = { "Специалист", "Специалист", "Старшый специалист", "Руководитель группы", "Начальник отдела" };
- while (true)
- {
- Console.WriteLine("1 - добавить досье\n2 - вывести все досье\n3 - удалить досье\n4 - поиск по фамилии\n5 - выход");
- Console.Write("Ввидите команду: ");
- string userInput = Console.ReadLine();
- Console.Clear();
- switch (userInput)
- {
- case "1":
- Console.Write("Ввидите фомилию: ");
- string userInputSurname = Console.ReadLine();
- Console.Write("Ввидите имя: ");
- string userInputName = Console.ReadLine();
- Console.Write("Ввидите отчество: ");
- string userInputPatronymic = Console.ReadLine();
- string userInputFullName = userInputSurname + " " + userInputName + " " + userInputPatronymic;
- AddDossier(ref fullName, userInputFullName);
- Console.Write("Ввидите должность: ");
- string userInputPost = Console.ReadLine();
- AddDossier(ref post, userInputPost);
- Console.WriteLine("Новое досье: " + userInputFullName + " - " + userInputPost);
- break;
- case "2":
- ShowDossier(fullName, post);
- break;
- case "3":
- Console.Write("Ввидите номер досье: ");
- int index = Convert.ToInt32(Console.ReadLine()) - 1;
- DeleteDossier(ref fullName, index);
- DeleteDossier(ref post, index);
- Console.WriteLine("Досье №" + (index + 1) + " удаленно.");
- break;
- case "4":
- SearchDossier(fullName, post, out userInputFullName);
- break;
- case "5":
- Environment.Exit(50);
- break;
- }
- Console.Write("Нажмите Enter чтобы вернуться в меню.");
- Console.ReadLine();
- Console.Clear();
- }
- }
- static void AddDossier(ref string[] Arrey, string userInput)
- {
- string[] tempArrey = new string[Arrey.Length + 1];
- tempArrey[tempArrey.Length - 1] = userInput;
- for (int i = 0; i < Arrey.Length; i++)
- {
- tempArrey[i] = Arrey[i];
- }
- Arrey = tempArrey;
- }
- static void ShowDossier(string[] fullName, string[] post)
- {
- for (int i = 0; i < fullName.Length; i++)
- {
- Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
- }
- }
- static void DeleteDossier(ref string[] Arrey, int index)
- {
- string[] tempArrey = new string[Arrey.Length - 1];
- for (int i = 0; i < index; i++)
- {
- tempArrey[i] = Arrey[i];
- }
- for (int i = index; i < tempArrey.Length; i++)
- {
- tempArrey[i] = Arrey[i + 1];
- }
- Arrey = tempArrey;
- }
- static void SearchDossier(string[] fullName, string[] post, out string userInputFullName)
- {
- bool employeeFound = false;
- Console.Write("Введите ФИО сотрудника через пробел: ");
- userInputFullName = Console.ReadLine();
- for (int i = 0; i < fullName.Length; i++)
- {
- if (userInputFullName.ToLower() == fullName[i].ToLower())
- {
- Console.WriteLine("Досье сотрудника: №" + (i + 1) + " " + fullName[i] + " - " + post[i]);
- employeeFound = true;
- break;
- }
- }
- if (employeeFound == false)
- {
- Console.WriteLine("Сотрудника с токой ФИО нету.");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment