Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- 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[] tableFullName = new string[0];
- string[] tablePost = 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 tableFullName, ref tablePost);
- break;
- case OutputEntireDossierCommand:
- OutputEntireDossier(ref tableFullName, ref tablePost);
- break;
- case DeleteDossierCommand:
- DeleteDossier(ref tableFullName, ref tablePost);
- break;
- case SearchBySurnameCommand:
- SearchBySurname(ref tableFullName, ref tablePost);
- break;
- case ExitCommand:
- Exit(ref isWorking);
- break;
- }
- }
- }
- static void AddDossier(ref string[] array1, ref string[] array2)
- {
- ArrayExtension(ref array1, "Введите ФИО сотрудника:");
- ArrayExtension(ref array2, "Введите должность сотрудника:");
- }
- static void ArrayExtension(ref 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;
- array = tempArray;
- }
- static void OutputEntireDossier(ref string[] array1, ref string[] array2)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Досье сотрудников:");
- Console.ForegroundColor = ConsoleColor.White;
- for (int i = 0; i < array1.Length; i++)
- {
- Console.WriteLine($"{i + 1})" + array1[i] + "-" + array2[i]);
- }
- Console.ReadKey();
- }
- static void DeleteDossier(ref string[] array1, ref string[] array2)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Введите номер досье которые вы хотите удалить:");
- Console.ForegroundColor = ConsoleColor.White;
- int deleteNumber = Convert.ToInt32(Console.ReadLine());
- if (deleteNumber < 0 || deleteNumber > array1.Length)
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Досье с таким номером не существет!");
- Console.ForegroundColor = ConsoleColor.White;
- Console.ReadKey();
- }
- ArrayReducing(ref array1, deleteNumber);
- ArrayReducing(ref array2, deleteNumber);
- }
- static void ArrayReducing(ref 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];
- }
- array = tempArray;
- }
- static void SearchBySurname(ref string[] array1,ref string[] array2)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Введите фамилию сотрудника:");
- Console.ForegroundColor = ConsoleColor.White;
- string surname = Console.ReadLine();
- for (int i = 0; i < array1.Length; i++)
- {
- if (array1[i] == surname)
- {
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine($"Сотрудник {surname} работает на должности {array2[i]}");
- Console.ForegroundColor = ConsoleColor.White;
- Console.ReadKey();
- break;
- }
- }
- }
- static bool Exit(ref bool isWorking)
- {
- isWorking = false;
- Console.ForegroundColor = ConsoleColor.Green;
- Console.WriteLine("Нажмите любую клавишу что-бы выйти из программы.");
- Console.ForegroundColor = ConsoleColor.White;
- return isWorking;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement