Advertisement
SnowPhoenix347

Untitled

Oct 30th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace FifthProject
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int menu;
  14.             int num = 0;
  15.             int equipped;
  16.             string[] weapon = new string[1];
  17.             int[] damage = new int[1];
  18.             int[] ammo = new int[1];
  19.  
  20.             string[] tempWeapon = new string[0];
  21.             int[] tempDamage = new int[0];
  22.             int[] tempAmmo = new int[0];
  23.  
  24.             while (true)
  25.             {
  26.                 if (ammo[num] != 0)
  27.                 {
  28.                     Console.WriteLine($"Экипированно: {weapon[num]}\n" +
  29.                                            $"Урон: {damage[num]}\n" +
  30.                                            $"Размер магазина: {ammo[num]}\n");
  31.                 }
  32.                
  33.                 Console.WriteLine("\tМеню\n" +
  34.                           "1. Добавить оружие.\n" +
  35.                           "2. Удалить оружие.\n" +
  36.                           "3. Экипировать оружие.");
  37.  
  38.                 menu = Convert.ToInt32(Console.ReadLine());
  39.  
  40.                 switch (menu)
  41.                 {
  42.                     case 1:
  43.                         Console.Write("Введите название для оружия: ");
  44.                         weapon[num] = Console.ReadLine();
  45.                         Console.Write("Введите его урон: ");
  46.                         damage[num] = Convert.ToInt32(Console.ReadLine());
  47.                         Console.Write("Введите размер магазина: ");
  48.                         ammo[num] = Convert.ToInt32(Console.ReadLine());
  49.  
  50.                         tempWeapon = new string[weapon.Length + 1];
  51.                         tempWeapon[num] = weapon[num];
  52.                         weapon = tempWeapon;
  53.                         tempDamage = new int[damage.Length + 1];
  54.                         tempDamage[num] = damage[num];
  55.                         damage = tempDamage;
  56.                         tempAmmo = new int[ammo.Length + 1];
  57.                         tempAmmo[num] = ammo[num];
  58.                         ammo = tempAmmo;
  59.  
  60.                         num++;
  61.                         break;
  62.                     case 2:
  63.                         Console.WriteLine("Какое оружие удалить?");
  64.                         for (int i = 0; i < weapon.Length - 1; i++)
  65.                         {
  66.                             Console.WriteLine($"Оружие номер {i + 1}: {weapon[i]}\n");
  67.                         }
  68.                         menu = Convert.ToInt32(Console.ReadLine());
  69.                         weapon[menu - 1] = null;
  70.                         int j = 0;
  71.                         tempWeapon = new string[weapon.Length];
  72.                         tempDamage = new int[weapon.Length];
  73.                         tempAmmo = new int[weapon.Length];
  74.  
  75.                         for (int i = 0; i < weapon.Length; i++)
  76.                         {
  77.                             if (weapon[j] == null)
  78.                             {
  79.                                 j++;
  80.                             }
  81.                             tempWeapon[i] = weapon[j];
  82.                             tempDamage[i] = damage[j];
  83.                             tempAmmo[i] = ammo[j];
  84.                             j++;
  85.                         }
  86.                         weapon = tempWeapon;
  87.                         damage = tempDamage;
  88.                         ammo = tempAmmo;
  89.                         break;
  90.                     case 3:
  91.                         Console.WriteLine("Какое оружие экипировать?");
  92.                         for (int i = 0; i < weapon.Length - 1; i++)
  93.                         {
  94.                             Console.WriteLine($"Оружие номер {i + 1}: {weapon[i]}\n");
  95.                         }
  96.                         equipped = Convert.ToInt32(Console.ReadLine());
  97.                         break;
  98.                     default:
  99.                         Console.WriteLine("Не верная команда");
  100.                         break;
  101.                 }
  102.                // Console.Clear();
  103.             }
  104.         }
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement