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 CSLight14
- {
- class Program
- {
- static void Main(string[] args)
- {
- string Comand = null;
- String[,] Array = new string[0, 0];
- string[] ActualGun = new string[3];
- Console.WriteLine("Введите одну из команд .\nДля добавления оружия'addgun'\nДля получения списка пушек 'listgun'\nДля удаления пушек 'deletegun'\nИспользовать оружие 'usegun'\n выход 'exit' ");
- while (Comand != "exit")
- {
- if (ActualGun[0] != null)
- {
- Console.WriteLine($"Экипировано {ActualGun[0]}\nУрон {ActualGun[1]}\nСкорострельность {ActualGun[2]} ");
- }
- Comand = Console.ReadLine().ToLower();
- switch (Comand)
- {
- case "listgun":
- listgun(ref Array);
- break;
- case "addgun":
- Addgun(ref Array);
- break;
- case "deletegun":
- Deletegun(ref Array, ref Comand);
- break;
- case "usegun":
- EquipGun(ref Array, ref ActualGun, ref Comand);
- break;
- default:
- Console.WriteLine("НЕПОНЯТНАА , ДАВАЙ ЕЩЁ РАЗ");
- break;
- };
- }
- }
- static void listgun(ref string[,] Array)
- {
- Console.WriteLine("Список ваших пушек");
- if (Array[0, 0] == null)
- {
- Console.WriteLine("Пуст");
- }
- else
- {
- for (int i = 0; i < Array.GetLength(0); i++)
- {
- Console.Write($"Пушка { Array[i, 0]} имеет: Урон { Array[i, 1]} Скорострельность { Array[i, 2]}");
- Console.WriteLine();
- }
- }
- }
- static void Addgun(ref string[,] Array)
- {
- string[,] tempArray = new string[Array.GetLength(0) + 1, 3];
- for (int i = 0; i < Array.GetLength(0); i++)
- {
- tempArray[i, 0] = Array[i, 0];
- }
- Console.WriteLine("Назовите вашу пушку!!");
- tempArray[tempArray.GetLength(0) - 1, 0] = Console.ReadLine();
- for (int i = 0; i < Array.GetLength(0); i++)
- {
- tempArray[i, 1] = Array[i, 1];
- }
- Console.WriteLine("Напчатайте сколько урона будет у пушки");
- tempArray[tempArray.GetLength(0) - 1, 1] = Convert.ToString(Console.ReadLine());
- for (int i = 0; i < Array.GetLength(0); i++)
- {
- tempArray[i, 2] = Array[i, 2];
- }
- Console.WriteLine("А теперь напишите скорострельность пушки");
- tempArray[tempArray.GetLength(0) - 1, 2] = Convert.ToString(Console.ReadLine());
- Array = tempArray;
- }
- static void Deletegun(ref string[,] Array, ref string Comand)
- {
- int l = 0;
- bool CheckComand = false;
- Console.WriteLine("Напишите имя пушки которую вы хотите удалить , с учётом регистров");
- Comand = Console.ReadLine();
- if (Array.GetLength(0) < 1)
- {
- Console.WriteLine("Ну и что ты собрался удалять ? , Оружейка пуста");
- }
- else if (Array[Array.GetLength(0) - 1, 0] == Comand)
- {
- CheckComand = true;
- string[,] TempArray = new string[Array.GetLength(0) - 1, 3];
- for (int i = 0; i < Array.GetLength(0) - 1; i++)
- {
- for (int j = 0; j < Array.GetLength(1); j++)
- {
- TempArray[i, j] = Array[i, j];
- }
- }
- Array = TempArray;
- Console.WriteLine($"Пушка {Comand} удалена");
- }
- else
- {
- string[,] TempArray = new string[Array.GetLength(0) - 1, 3];
- for (int i = 0; i < Array.GetLength(0) - 1; i++)
- {
- if (Array[i, 0] == Comand)
- {
- CheckComand = true;
- l++;
- }
- for (int j = 0; j < Array.GetLength(1); j++)
- {
- TempArray[i, j] = Array[l, j];
- }
- l++;
- }
- if (CheckComand)
- {
- Array = TempArray;
- Console.WriteLine($"Пушка {Comand} удалена");
- }
- else
- {
- Console.WriteLine("Такой пушки нету");
- }
- }
- }
- static void EquipGun(ref string[,] Array, ref string[] ActualGun, ref string Comand)
- {
- Console.WriteLine("Что хочешь экипировать , пиши с учётом регистров");
- Comand = Console.ReadLine();
- for (int i = 0; i < Array.GetLength(0); i++)
- {
- if (Array[i, 0] == Comand)
- {
- ActualGun[0] = Array[i, 0];
- ActualGun[1] = Array[i, 1];
- ActualGun[2] = Array[i, 2];
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement