2629881

Untitled

Jul 30th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 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 ekwipunek
  8. {
  9.     public class Inventory
  10.     {
  11.         string[] arrayItems = new string[6];
  12.        
  13.          
  14.         public void AddItem(string item)
  15.         {
  16.             arrayItems[0] = item;
  17.         }
  18.  
  19.         public void DisplayItems()
  20.         {
  21.             foreach (string item in arrayItems)
  22.             {
  23.                 Console.Write(item + ";");
  24.             }
  25.         }
  26.     }
  27.  
  28.     class Program
  29.     {
  30.         static void Main(string[] args)
  31.         {
  32.             Inventory ekwipunek = new Inventory();
  33.             Console.WriteLine("Wpisz komende /add /switch /displayall");
  34.             // test
  35.             ekwipunek.DisplayItems();
  36.             Console.WriteLine();
  37.             // test
  38.  
  39.  
  40.  
  41.             while (true)
  42.             {
  43.                 string command = Console.ReadLine();
  44.                 switch (command)
  45.                 {
  46.                     case "/displayall":
  47.                         ekwipunek.DisplayItems();
  48.                         Console.WriteLine();
  49.                         break;
  50.                     case "/add":
  51.                         string item = Console.ReadLine(); ;
  52.                         ekwipunek.AddItem(item);
  53.                         Console.WriteLine("{0} has been added to your inventory", item);
  54.                         break;
  55.                     case "/switch":
  56.                         break;
  57.                 }
  58.             }
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment