Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- string [] namesArray = new string [0];
- string [] positionsArray = new string [0];
- string userInput;
- do
- {
- Console.WriteLine("1. Добавить досье");
- Console.WriteLine("2. Вывести все досье");
- Console.WriteLine("3. Удалить досье");
- Console.WriteLine("4. Выход");
- Console.WriteLine("Введите нужный пункт меню");
- userInput = Console.ReadLine();
- switch (userInput)
- {
- case "1":
- AddNewDosje(ref namesArray, ref positionsArray);
- Console.Clear();
- break;
- case "2":
- PrintDosje(namesArray, positionsArray);
- break;
- case "3":
- DeleteDosje(ref namesArray, ref positionsArray);
- break;
- case "4":
- break;
- }
- } while (userInput != "4");
- }
- static void AddNewDosje( ref string[] namesArray, ref string[] positionsArray)
- {
- Console.WriteLine("Введите Фамилию Имя Отчество\n");
- string name = Console.ReadLine();
- Console.WriteLine("Введите должность\n");
- string position = Console.ReadLine();
- string[] tempNamesArray = new string[namesArray.Length + 1];
- for (int i = 0; i < namesArray.Length; i++)
- {
- tempNamesArray[i] = namesArray[i];
- }
- namesArray = tempNamesArray;
- namesArray[namesArray.Length - 1] = name;
- string[] tempPositionsArray = new string[positionsArray.Length + 1];
- for (int i = 0; i < positionsArray.Length; i++)
- {
- tempPositionsArray[i] = positionsArray[i];
- }
- positionsArray = tempPositionsArray;
- positionsArray[positionsArray.Length - 1] = position;
- }
- static void PrintDosje(string[] namesArray, string[] positionsArray)
- {
- Console.Clear();
- for (int i = 0; i < namesArray.Length; i++)
- {
- Console.WriteLine((i + 1) + ". " + namesArray[i] + " - " + positionsArray[i]);
- }
- Console.ReadLine();
- Console.Clear();
- }
- static void DeleteDosje(ref string[] namesArray, ref string[] positionsArray)
- {
- Console.WriteLine("Введите Фамилию человека, досье которого вы хотите удалить\n");
- string name = Console.ReadLine();
- for (int i = 0; i < namesArray.Length; i++)
- {
- if (namesArray[i] == name)
- {
- Console.WriteLine("Досье найдено !\n");
- Console.WriteLine((i + 1) + ". " + namesArray[i] + " - " + positionsArray[i] +"\n");
- Console.WriteLine("Нажмите Enter, чтобы удалить досье");
- Console.ReadLine();
- namesArray[i] = null;
- positionsArray[i] = null;
- Console.WriteLine("Досье удалено !\n");
- Console.WriteLine("Для выхода в меню нажмите Enter");
- Console.ReadLine();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement