Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Tasks
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] name = { "Петров Анатолий Поликарпович", "Сидоров Святослав Иванович" };
- string[] position = { "Завхоз", "Большая насяльника" };
- bool exit = true;
- MenuDraw();
- while (exit)
- {
- int userInput = Convert.ToInt32(Console.ReadLine());
- switch (userInput)
- {
- case 1:
- Console.Clear();
- Console.WriteLine("Введите ФИО: ");
- AddDossier(ref name);
- Console.WriteLine("Введите должность: ");
- AddDossier(ref position);
- MenuDraw();
- break;
- case 2:
- Console.Clear();
- WriteDossiers(name, position);
- MenuDraw();
- break;
- case 3:
- Console.Clear();
- Console.WriteLine("Введите порядковый номер удаляемого досье.");
- int deleteNumber = Convert.ToInt32(Console.ReadLine());
- DeleteDossier(ref name, deleteNumber);
- DeleteDossier(ref position, deleteNumber);
- MenuDraw();
- break;
- case 4:
- Console.Clear();
- FindDossier(name, position);
- MenuDraw();
- break;
- case 5:
- exit = false;
- break;
- default:
- Console.WriteLine("Такой команды нет.");
- break;
- }
- }
- }
- static void AddDossier(ref string[] increasingArray)
- {
- Array.Resize(ref increasingArray, increasingArray.Length + 1);
- string newInput = Console.ReadLine();
- increasingArray[increasingArray.Length - 1] = newInput;
- }
- static void WriteDossiers(string[] showNameArray, string[] showPositionArray)
- {
- for (int i = 0; i < showNameArray.Length; i++)
- {
- Console.Write(i + 1 + " ");
- Console.Write(showNameArray[i] + "-");
- Console.Write(showPositionArray[i] + ". ");
- }
- Console.WriteLine("");
- }
- static void DeleteDossier(ref string[] decreasingArray, int removableDossierIndex)
- {
- if (removableDossierIndex < 1 || removableDossierIndex > decreasingArray.Length)
- {
- Console.WriteLine("Досье с таким номером не существует!");
- }
- else
- {
- string[] newName = new string[decreasingArray.Length - 1];
- for (int i = 0; i < decreasingArray.Length; i++)
- {
- if (i < (removableDossierIndex - 1))
- {
- newName[i] = decreasingArray[i];
- }
- else if (i > (removableDossierIndex - 1))
- {
- newName[i - 1] = decreasingArray[i];
- }
- }
- decreasingArray = newName;
- }
- }
- static void FindDossier(string[] arrayForSearching, string[] arrayToShowPosition)
- {
- Console.WriteLine("Введите фамилию");
- string secondNameInput = Console.ReadLine();
- string secondName = secondNameInput.ToLower();
- bool secondNameFound = false;
- for (int i = 0; i < arrayForSearching.Length; i++)
- {
- bool comparision = arrayForSearching[i].ToLower().Contains(secondName);
- if (comparision == true)
- {
- Console.WriteLine(i + 1 + "." + arrayForSearching[i] + "." + arrayToShowPosition[i]);
- secondNameFound = true;
- break;
- }
- }
- if (secondNameFound == false)
- {
- Console.WriteLine("Такого сотрудника нетЮ.");
- }
- }
- static void MenuDraw()
- {
- Console.WriteLine();
- Console.WriteLine("Здравствуйте, что вы хотите сделать?");
- Console.WriteLine("1 - добавить досье.");
- Console.WriteLine("2 - вывести все досье.");
- Console.WriteLine("3 - удалить досье.");
- Console.WriteLine("4 - найти работника по фамилии.");
- Console.WriteLine("5 - выход.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement