Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.15 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace CSLight14
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             string Comand = null;
  15.  
  16.             String[,] Array = new string[0, 0];
  17.  
  18.             string[] ActualGun = new string[3];
  19.  
  20.             Console.WriteLine("Введите одну из команд .\nДля добавления оружия'addgun'\nДля получения списка пушек 'listgun'\nДля удаления пушек 'deletegun'\nИспользовать оружие 'usegun'\n выход 'exit' ");
  21.  
  22.  
  23.             while (Comand != "exit")
  24.             {
  25.                 if (ActualGun[0] != null)
  26.                 {
  27.                     Console.WriteLine($"Экипировано {ActualGun[0]}\nУрон {ActualGun[1]}\nСкорострельность {ActualGun[2]} ");
  28.                 }
  29.  
  30.  
  31.                 Comand = Console.ReadLine().ToLower();
  32.  
  33.  
  34.                 switch (Comand)
  35.                 {
  36.                     case "listgun":
  37.  
  38.                         listgun(ref Array);
  39.  
  40.                         break;
  41.  
  42.                     case "addgun":
  43.  
  44.                         Addgun(ref Array);
  45.  
  46.                         break;
  47.  
  48.                     case "deletegun":
  49.  
  50.                         Deletegun(ref Array, ref Comand);
  51.  
  52.                         break;
  53.  
  54.                     case "usegun":
  55.  
  56.                         EquipGun(ref Array, ref ActualGun, ref Comand);
  57.  
  58.                         break;
  59.  
  60.  
  61.                     default:
  62.  
  63.                         Console.WriteLine("НЕПОНЯТНАА , ДАВАЙ ЕЩЁ РАЗ");
  64.                         break;
  65.  
  66.                 };
  67.  
  68.  
  69.             }
  70.         }
  71.  
  72.         static void listgun(ref string[,] Array)
  73.         {
  74.  
  75.             Console.WriteLine("Список ваших пушек");
  76.             if (Array[0, 0] == null)
  77.             {
  78.                 Console.WriteLine("Пуст");
  79.             }
  80.             else
  81.             {
  82.                 for (int i = 0; i < Array.GetLength(0); i++)
  83.                 {
  84.  
  85.                     Console.Write($"Пушка { Array[i, 0]} имеет: Урон { Array[i, 1]}  Скорострельность { Array[i, 2]}");
  86.  
  87.                     Console.WriteLine();
  88.                 }
  89.             }
  90.         }
  91.  
  92.         static void Addgun(ref string[,] Array)
  93.         {
  94.             string[,] tempArray = new string[Array.GetLength(0) + 1, 3];
  95.  
  96.             for (int i = 0; i < Array.GetLength(0); i++)
  97.             {
  98.                 tempArray[i, 0] = Array[i, 0];
  99.             }
  100.  
  101.             Console.WriteLine("Назовите вашу пушку!!");
  102.             tempArray[tempArray.GetLength(0) - 1, 0] = Console.ReadLine();
  103.  
  104.             for (int i = 0; i < Array.GetLength(0); i++)
  105.             {
  106.                 tempArray[i, 1] = Array[i, 1];
  107.             }
  108.  
  109.             Console.WriteLine("Напчатайте сколько урона будет у пушки");
  110.             tempArray[tempArray.GetLength(0) - 1, 1] = Convert.ToString(Console.ReadLine());
  111.  
  112.             for (int i = 0; i < Array.GetLength(0); i++)
  113.             {
  114.                 tempArray[i, 2] = Array[i, 2];
  115.             }
  116.  
  117.             Console.WriteLine("А теперь напишите скорострельность пушки");
  118.             tempArray[tempArray.GetLength(0) - 1, 2] = Convert.ToString(Console.ReadLine());
  119.  
  120.             Array = tempArray;
  121.         }
  122.  
  123.         static void Deletegun(ref string[,] Array, ref string Comand)
  124.         {
  125.  
  126.             int l = 0;
  127.  
  128.             bool CheckComand = false;
  129.  
  130.             Console.WriteLine("Напишите имя пушки которую вы хотите удалить , с учётом регистров");
  131.  
  132.             Comand = Console.ReadLine();
  133.  
  134.             if (Array.GetLength(0) < 1)
  135.             {
  136.                 Console.WriteLine("Ну и что ты собрался удалять ? , Оружейка пуста");
  137.             }
  138.             else if (Array[Array.GetLength(0) - 1, 0] == Comand)
  139.             {
  140.  
  141.                 CheckComand = true;
  142.  
  143.                 string[,] TempArray = new string[Array.GetLength(0) - 1, 3];
  144.  
  145.                 for (int i = 0; i < Array.GetLength(0) - 1; i++)
  146.                 {
  147.                     for (int j = 0; j < Array.GetLength(1); j++)
  148.                     {
  149.                         TempArray[i, j] = Array[i, j];
  150.                     }
  151.                 }
  152.  
  153.                 Array = TempArray;
  154.  
  155.                 Console.WriteLine($"Пушка {Comand} удалена");
  156.             }
  157.             else
  158.             {
  159.  
  160.  
  161.  
  162.                 string[,] TempArray = new string[Array.GetLength(0) - 1, 3];
  163.  
  164.                 for (int i = 0; i < Array.GetLength(0) - 1; i++)
  165.                 {
  166.                     if (Array[i, 0] == Comand)
  167.                     {
  168.                         CheckComand = true;
  169.                         l++;
  170.                     }
  171.  
  172.  
  173.                     for (int j = 0; j < Array.GetLength(1); j++)
  174.                     {
  175.                         TempArray[i, j] = Array[l, j];
  176.                     }
  177.  
  178.                     l++;
  179.                 }
  180.  
  181.                 if (CheckComand)
  182.                 {
  183.                     Array = TempArray;
  184.  
  185.                     Console.WriteLine($"Пушка {Comand} удалена");
  186.                 }
  187.                 else
  188.                 {
  189.                     Console.WriteLine("Такой пушки нету");
  190.                 }
  191.  
  192.  
  193.             }
  194.         }
  195.  
  196.         static void EquipGun(ref string[,] Array, ref string[] ActualGun, ref string Comand)
  197.         {
  198.             Console.WriteLine("Что хочешь экипировать , пиши с учётом регистров");
  199.  
  200.             Comand = Console.ReadLine();
  201.  
  202.             for (int i = 0; i < Array.GetLength(0); i++)
  203.             {
  204.                 if (Array[i, 0] == Comand)
  205.                 {
  206.                     ActualGun[0] = Array[i, 0];
  207.                     ActualGun[1] = Array[i, 1];
  208.                     ActualGun[2] = Array[i, 2];
  209.                 }
  210.             }
  211.  
  212.         }
  213.     }
  214. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement