Advertisement
2629881

Untitled

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