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 Task1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.SetWindowSize(100, 55);
- string[] fullNames = new string[0];
- string[] posts = new string[0];
- string[] fullNamesStaff = new string[]
- {
- "Колесников Андрей Викторович",
- "Кондратьев Владимир Сергеевич",
- "Соловьёв Михаил Юрьевич",
- "Максимов Александр Константинович",
- "Петров Илья Валерьеви"
- };
- string[] postsStaff = new string[]
- {
- "CEO",
- "Project Manager",
- "Middle developer",
- "Junior developer",
- "QA tester"
- };
- string command = "";
- while (command != "/exit")
- {
- Console.WriteLine("Меню. Выберите команду");
- Console.WriteLine("/add - добавить досье\n/addstaff - добавить штатных сотрудников" +
- "\n/remove - удалить досье\n/show - вывести все досье" +
- "\n/search - поиск досье по фамилии\n/exit - выход из программы");
- command = Console.ReadLine().ToLower();
- if (command == "/add")
- {
- Console.WriteLine("Введите ФИО:");
- string fullName = Console.ReadLine();
- Console.WriteLine($"Введите должность сотрудника: {fullName}");
- string post = Console.ReadLine();
- fullNames = Add(fullNames, fullName);
- posts = Add(posts, post);
- Console.Clear();
- }
- else if(command == "/addstaff")
- {
- Console.Clear();
- fullNames = Add(fullNames, fullNamesStaff);
- posts = Add(posts, postsStaff);
- }
- else if (command == "/remove")
- {
- Console.WriteLine("Введите ФИО сотрудника которого вы хотите удалить");
- string remove = Console.ReadLine();
- int indexRemove;
- fullNames = Remove(fullNames, remove, out indexRemove);
- posts = Remove(posts, posts[indexRemove], out indexRemove);
- Console.Clear();
- }
- else if (command == "/show")
- {
- Console.Clear();
- Show(fullNames, posts);
- }
- else if (command == "/search")
- {
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Такой команды нет!");
- Console.ResetColor();
- }
- }
- }
- //------------------------------------------------------------------------------------------------------
- static string[] Add(string[] array, string addedElement)
- {
- string[] tempArray = new string[array.Length + 1];
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- }
- tempArray[tempArray.Length - 1] = addedElement;
- return tempArray;
- }
- static string[] Add(string[] array, string[] addedArray)
- {
- string[] tempArray = new string[array.Length + addedArray.Length];
- int tempIndex = 0;
- for (int i = 0; i < array.Length; i++)
- {
- tempArray[i] = array[i];
- tempIndex = i + 1;
- }
- for (int i = 0; i < addedArray.Length; i++)
- {
- tempArray[tempIndex + i] = addedArray[i];
- }
- return tempArray;
- }
- static string[] Remove(string[] array, string remove, out int indexRemove)
- {
- string[] tempArray = new string[array.Length - 1];
- int tempIndex = 0;
- for (int i = 0; i < array.Length; i++)
- {
- if(array[i] != remove)
- {
- tempArray[i] = array[i];
- }
- else
- {
- tempIndex = i;
- break;
- }
- }
- for (int i = tempIndex; i < array.Length - 1; i++)
- {
- tempArray[i] = array[i + 1];
- }
- indexRemove = tempIndex;
- return tempArray;
- }
- static void Search()
- {
- }
- static void Show(string[] fullNames, string[] posts, int left = 0, int top = 15)
- {
- Console.SetCursorPosition(left, top);
- Console.ForegroundColor = ConsoleColor.Green;
- if (fullNames.Length == posts.Length)
- {
- for (int i = 0; i < fullNames.Length; i++)
- {
- Console.WriteLine($"{i + 1}. {fullNames[i]} - {posts[i]}");
- }
- }
- else
- {
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine("Кол-во ФИО и должностей должны быть одинаковыми!");
- Console.ResetColor();
- }
- Console.ResetColor();
- Console.SetCursorPosition(0, 0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement