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 ConsoleApp17
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] namesArray = { " Иванов А.А.", " Петров Б.Б. ", " Стрелков В.В." };
- string[] positionArray = { " Наемник", " Торговец", " Алхимик" };
- int UserInput;
- String NewName;
- String NewPosition;
- bool needToExit = false;
- while (needToExit == false)
- {
- Console.WriteLine("\nДоступные команды:\n1 - добавить досье \n2 - вывести все досье \n3 - удалить досье \n4 - выход ");
- UserInput = int.Parse(Console.ReadLine());
- switch (UserInput)
- {
- case 1:
- Console.WriteLine("Введите ФИО");
- NewName = Console.ReadLine();
- namesArray = ExpandArray(namesArray, NewName);
- Console.WriteLine("Введите должность");
- NewPosition = Console.ReadLine();
- positionArray = ExpandArray(positionArray, NewPosition);
- break;
- case 2:
- if (namesArray.Length > 0 && positionArray.Length > 0)
- {
- Console.WriteLine("");
- DisplayArray(namesArray, positionArray);
- }
- else
- {
- Console.WriteLine("Досье пусты...");
- }
- break;
- case 3:
- if (namesArray.Length > 0 && positionArray.Length > 0)
- {
- namesArray = DecreaseArray(namesArray);
- positionArray = DecreaseArray(positionArray);
- Console.WriteLine("Удалено последнее досье с конца списка");
- }
- else
- {
- Console.WriteLine("Досье пусты...");
- }
- break;
- case 4:
- Console.WriteLine("Выход из программы...");
- needToExit = true;
- break;
- default:
- Console.WriteLine("Выберите одну из 4х команд");
- break;
- }
- }
- }
- static string[] ExpandArray(string[] arrays, string arrayElement)
- {
- string[] tempArray = new string[arrays.Length + 1];
- for (int i = 0; i < arrays.Length; i++)
- {
- tempArray[i] = arrays[i];
- }
- tempArray[tempArray.Length - 1] = " " + arrayElement;
- arrays = tempArray;
- return arrays;
- }
- static void DisplayArray (string[] arrays, string[] addArrays)
- {
- for (int i = 0; i < arrays.Length; i++)
- {
- Console.WriteLine((i+1) + ". - " + arrays[i] + " -" + addArrays[i]);
- }
- }
- static string[] DecreaseArray(string[] arrays)
- {
- string[] tempArray = new string[arrays.Length - 1];
- for (int i = 0; i < (arrays.Length - 1); i++)
- {
- tempArray[i] = arrays[i];
- }
- arrays = tempArray;
- return arrays;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement