Benjail

3.8

Aug 31st, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.70 KB | None | 0 0
  1. using System;
  2.  
  3. namespace IMJunior
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string[] ekip = new string[0];
  10.             string[] uron = new string[0];
  11.             string[] skor = new string[0];
  12.             while (true)
  13.             {
  14. //Вывод всего арсенала:              
  15.                 Console.WriteLine("Арсенал");
  16.                 Console.Write("Экипировано: \n");
  17.                 for (int i = 0; i < ekip.Length; i++)
  18.                     Console.WriteLine(i + 1 + ") " + ekip[i]);
  19.  
  20.                 Console.Write("Урон -  \n");
  21.                 for (int i = 0; i < ekip.Length; i++)
  22.                     Console.WriteLine(i + 1 + ") " + uron[i]);
  23.  
  24.                 Console.Write("Скорострельность - \n");
  25.                 for (int i = 0; i < ekip.Length; i++)
  26.                     Console.WriteLine(i + 1 + ") " + skor[i] + " ");
  27. //Меню:
  28.                 Console.WriteLine("Меню\n1) Добавить оружие\n2) Экипировать оружие\n3) Удалить оружие");
  29.                 string sw = Console.ReadLine();
  30.                 switch (sw)
  31.                 {
  32.                     case "1":
  33.                         string eki = " ";
  34.                         string urn = " ";
  35.                         string skr = " ";
  36.                         Console.Write("Экипировано: ");
  37.                         eki = Console.ReadLine();
  38.                         string[] tempekip = new string[ekip.Length + 1]; //увеличение массива
  39.                         for (int i = 0; i < ekip.Length; i++)
  40.                         {      
  41.                             tempekip[i] = ekip[i];      
  42.                         }      
  43.                         tempekip[tempekip.Length - 1] = eki;        
  44.                         ekip = tempekip;    
  45.                         Console.WriteLine();    
  46.  
  47.                         Console.Write("Урон - ");
  48.                         urn = Console.ReadLine();
  49.                         string[] tempuron = new string[uron.Length + 1]; //увеличение массива
  50.                         for (int i = 0; i < uron.Length; i++)
  51.                         {
  52.                             tempuron[i] = uron[i];
  53.                         }
  54.                         tempuron[tempuron.Length - 1] = urn;
  55.                         uron = tempuron;
  56.                         Console.WriteLine();
  57.  
  58.                         Console.Write("Cкорострельность - ");
  59.                         skr = Console.ReadLine();
  60.                         string[] tempskor = new string[skor.Length + 1]; //увеличение массива
  61.                         for (int i = 0; i < skor.Length; i++)
  62.                         {
  63.                             tempskor[i] = skor[i];
  64.                         }
  65.                         tempskor[tempskor.Length - 1] = urn;
  66.                         skor = tempskor;
  67.                         Console.WriteLine();
  68.                         break;
  69.  
  70.                     case "2":                                
  71.                         Console.Write("Введите номер оружия для экипировки: ");
  72.                         int number = Convert.ToInt32(Console.ReadLine());
  73.                         Console.WriteLine("Что вы хотите поменять: \n1) Экипировано\n2) Урон\n3) Скорострельность\n");
  74.                         string menu = Console.ReadLine();
  75.                         switch (menu)
  76.                         {
  77.                             case "1":
  78.                                 Console.WriteLine("Введите название: ");
  79.                                 ekip[number - 1] = Console.ReadLine();
  80.                                 break;
  81.                             case "2":
  82.                                 Console.WriteLine("Введите урон: ");
  83.                                 ekip[number - 1] = Console.ReadLine();
  84.                                 break;
  85.                             case "3":
  86.                                 Console.WriteLine("Введите скорострельность: ");
  87.                                 ekip[number - 1] = Console.ReadLine();
  88.                                 break;
  89.                             default:
  90.                                 break;
  91.                         }
  92.                         break;
  93.  
  94.                     case "3":
  95.                         Console.Write("Введите номер оружия, которое хотите удалить: ");
  96.                         string numdel = Console.ReadLine();
  97.                          tempekip = new string[ekip.Length-1]; //уменьшение  массива ekip
  98.                         for (int i = 0; i < tempekip.Length; i++)
  99.                         {
  100.                             if (i != Convert.ToInt32(numdel)-1) // условие непопадания в уменьшенный массив удаленного элемента
  101.                             {
  102.                                 tempekip[i] = ekip[i];
  103.                             }                        
  104.                         }                        
  105.                         ekip = tempekip;                
  106.                                          
  107.                          tempuron = new string[uron.Length - 1]; //уменьшение массива uron
  108.                         for (int i = 0; i < tempuron.Length; i++)
  109.                         {
  110.                             if (i != Convert.ToInt32(numdel) - 1) // условие непопадания в уменьшенный массив удаленного элемента
  111.                             {
  112.                                 tempuron[i] = uron[i];
  113.                             }
  114.                         }
  115.                        
  116.                         uron = tempuron;      
  117.                        
  118.                          tempskor = new string[skor.Length - 1]; //уменьшение  массива skor
  119.                         for (int i = 0; i < tempskor.Length; i++)
  120.                         {
  121.                             if (i != Convert.ToInt32(numdel) - 1) //условие непопадания в уменьшенный массив удаленного элемента
  122.                             {
  123.                                 tempskor[i] = skor[i];
  124.                             }
  125.                         }                        
  126.                         skor = tempskor;                        
  127.                         break;
  128.  
  129.                     default:
  130.                         break;
  131.                 }
  132.                 Console.Clear();
  133.             }
  134.         }
  135.     }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment