Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static void Main(string[] args)
- {
- const string AddDossierCommand = "1";
- const string OutputEntireDossierCommand = "2";
- const string DeleteDossierCommand = "3";
- const string SearchBySurnameCommand = "4";
- const string ExitCommand = "5";
- string[] tableFullNames = new string[0];
- string[] tablePosts = new string[0];
- string userInput;
- bool isWorking = true;
- while (isWorking)
- {
- Console.Clear();
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Выберите действие:");
- Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine($"{AddDossierCommand} <-- Добавить досье.\n{OutputEntireDossierCommand} <-- Вывод всего досье.\n{DeleteDossierCommand}" +
- $" <-- Удалить досье\n{SearchBySurnameCommand} <-- Поиск по фамилии.\n{ExitCommand} <-- Выход.");
- userInput = Console.ReadLine();
- Console.Clear();
- switch (userInput)
- {
- case AddDossierCommand:
- AddDossier(ref tableFullNames, ref tablePosts);
- break;
- case OutputEntireDossierCommand:
- OutputEntireDossier(ref tableFullNames, ref tablePosts);
- break;
- case DeleteDossierCommand:
- DeleteDossier(ref tableFullNames, ref tablePosts);
- break;
- case SearchBySurnameCommand:
- SearchBySurname(ref tableFullNames, ref tablePosts);
- break;
- case ExitCommand:
- isWorking = Exit(isWorking);
- break;
- }
- }
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Нажмите любую клавишу что-бы выйти из программы.");
- Console.ForegroundColor = ConsoleColor.White;
- }
- static void AddDossier(ref string[] arrayFullNames, ref string[] arrayPosts)
- {
- arrayFullNames = ArrayExtension(arrayFullNames, "Введите ФИО сотрудника:");
- arrayPosts = ArrayExtension(arrayPosts, "Введите должность сотрудника:");
- }
- static string[] ArrayExtension(string[] array, string text)
- {
- string[] tempArray = new string[array.Length + 1];
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine(text);
- Console.ForegroundColor = ConsoleColor.White;
- string word = Console.ReadLine();
- tempArray[tempArray.Length - 1] = word;
- return tempArray;
- }
- static void OutputEntireDossier(ref string[] arrayFullNames, ref string[] arrayPosts)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Досье сотрудников:");
- Console.ForegroundColor = ConsoleColor.White;
- for (int i = 0; i < arrayFullNames.Length; i++)
- {
- Console.WriteLine($"{i + 1})" + arrayFullNames[i] + "-" + arrayPosts[i]);
- }
- Console.ReadKey();
- }
- static void DeleteDossier(ref string[] arrayFullNames, ref string[] arrayPosts)
- {
- bool isExit = true;
- while (isExit)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Введите номер досье которые вы хотите удалить:");
- Console.ForegroundColor = ConsoleColor.White;
- int deleteNumber = Convert.ToInt32(Console.ReadLine());
- if (deleteNumber < 0 || deleteNumber > arrayFullNames.Length)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Досье с таким номером не существует!");
- Console.ForegroundColor = ConsoleColor.White;
- Console.ReadKey();
- Console.Clear();
- }
- else
- {
- arrayFullNames = ArrayReducing(arrayFullNames, deleteNumber);
- arrayPosts = ArrayReducing(arrayPosts, deleteNumber);
- isExit = false;
- }
- }
- }
- static string[] ArrayReducing(string[] array, int number)
- {
- for (int i = (number - 1); i < array.Length - 1; i++)
- {
- array[i] = array[i + 1];
- }
- string[] tempArray = new string[array.Length - 1];
- for (int i = 0; i < tempArray.Length; i++)
- {
- tempArray[i] = array[i];
- }
- return tempArray;
- }
- static void SearchBySurname(ref string[] arrayFullNames,ref string[] arrayPost)
- {
- char symbol = ' ';
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Введите фамилию сотрудника:");
- Console.ForegroundColor = ConsoleColor.White;
- string surname = Console.ReadLine();
- for (int i = 0; i < arrayFullNames.Length; i++)
- {
- string[] words = arrayFullNames[i].Split(symbol);
- if (words[i] == surname)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine($"Сотрудник {surname} работает на должности {arrayPost[i]}");
- Console.ForegroundColor = ConsoleColor.White;
- Console.ReadKey();
- break;
- }
- }
- }
- static bool Exit(bool isWorking)
- {
- isWorking = false;
- return isWorking;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement