Advertisement
SnowPhoenix347

3.8

Nov 1st, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.07 KB | None | 0 0
  1. using System;
  2. using System.Diagnostics;
  3.  
  4. namespace FifthProject
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string[] weapon = new string[1];
  11.             int[] damage = new int[1];
  12.             int[] ammo = new int[1];
  13.  
  14.             int menu;
  15.             int number = 0;
  16.             int equiped = 0;
  17.             bool outfitted = false;
  18.            
  19.             while (true)
  20.             {
  21.                 if (outfitted)
  22.                 {
  23.                     Console.WriteLine($"Outfitted: {weapon[equiped]}\n" +
  24.                                       $"Damage: {damage[equiped]}\n" +
  25.                                       $"Ammo: {ammo[equiped]}\n");
  26.                 }
  27.                
  28.                 Console.WriteLine($"\tMenu\n" +
  29.                                   $"1. Add weapon\n" +
  30.                                   $"2. Remove weapon\n" +
  31.                                   $"3. Equip weapon\n");
  32.                
  33.                 menu = Convert.ToInt32(Console.ReadLine());
  34.  
  35.                 if (menu > 3)
  36.                 {
  37.                     Console.Clear();
  38.                     continue;
  39.                 }
  40.                 switch(menu)
  41.                 {
  42.                     case 1:
  43.                         Console.Write("Enter name: ");
  44.                         weapon[number] = Console.ReadLine();
  45.                         string[] tempWeapon = new string[weapon.Length + 1];
  46.                        
  47.                         Console.Write("\nEnter Damage: ");
  48.                         damage[number] = Convert.ToInt32(Console.ReadLine());
  49.                          int[] tempDamage = new int[damage.Length + 1];
  50.                        
  51.                         Console.Write("\nEnter the size of the magazine: ");
  52.                         ammo[number] = Convert.ToInt32(Console.ReadLine());
  53.                         int[] tempAmmo = new int[ammo.Length + 1];
  54.                        
  55.                         for (int i = 0; i < weapon.Length; i++)
  56.                         {
  57.                             tempWeapon[i] = weapon[i];
  58.                         }
  59.                         weapon = tempWeapon;
  60.                         for (int i = 0; i < damage.Length; i++)
  61.                         {
  62.                             tempDamage[i] = damage[i];
  63.                         }
  64.                         damage = tempDamage;
  65.                         for (int i = 0; i < ammo.Length; i++)
  66.                         {
  67.                             tempAmmo[i] = ammo[i];
  68.                         }
  69.                         ammo = tempAmmo;
  70.                        
  71.                         number++;
  72.                         break;
  73.                     case 2:
  74.                         Console.Write("Enter slot: \n");
  75.                         for (int i = 0; i < weapon.Length - 1; i++)
  76.                         {
  77.                             Console.WriteLine($"{i + 1}. {weapon[i]}");
  78.                         }
  79.                         int deleteMenu = Convert.ToInt32(Console.ReadLine());
  80.                         weapon[deleteMenu - 1] = null;
  81.                        
  82.                         string[] tempWeapon2 = new string[weapon.Length - 1];
  83.                         int[] tempDamage2 = new int[weapon.Length - 1];
  84.                         int[] tempAmmo2 = new int[ammo.Length - 1];
  85.                        
  86.                         for (int i = 0; i < weapon.Length - 1; i++)
  87.                         {
  88.                             if (weapon[i] != null)
  89.                             {
  90.                                 tempWeapon2[i] = weapon[i];
  91.                                 tempDamage2[i] = damage[i];
  92.                                 tempAmmo2[i] = ammo[i];
  93.                             }
  94.                             else
  95.                             {
  96.                                 tempWeapon2[i] = weapon[i+1];
  97.                                 tempDamage2[i] = damage[i+1];
  98.                                 tempAmmo2[i] = ammo[i+1];
  99.                             }
  100.                         }
  101.  
  102.                         weapon = tempWeapon2;
  103.                         damage = tempDamage2;
  104.                         ammo = tempAmmo2;
  105.  
  106.                         number--;
  107.                         break;
  108.                     case 3:
  109.                         Console.WriteLine("Select a slot");
  110.                         for (int i = 0; i < weapon.Length - 1; i++)
  111.                         {
  112.                             Console.WriteLine($"{i + 1}. {weapon[i]}");
  113.                         }
  114.                         equiped = Convert.ToInt32(Console.ReadLine()) - 1;
  115.                         if (equiped >= weapon.Length - 1)
  116.                         {
  117.                             equiped = 0;
  118.                         }
  119.                         break;
  120.                 }
  121.                 if (weapon.Length == 0)
  122.                 {
  123.                     outfitted = false;
  124.                 }
  125.                 else
  126.                 {
  127.                     outfitted = true;
  128.                 }
  129.                
  130.                 Console.Clear();
  131.             }
  132.         }
  133.     }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement