Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ekwipunek
- {
- public class Inventory
- {
- string[] arrayItems = new string[6];
- public void AddItem(string item)
- {
- arrayItems[0] = item;
- }
- public void DisplayItems()
- {
- foreach (string item in arrayItems)
- {
- Console.Write(item + ";");
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Inventory ekwipunek = new Inventory();
- Console.WriteLine("Wpisz komende /add /switch /displayall");
- // test
- ekwipunek.DisplayItems();
- Console.WriteLine();
- // test
- while (true)
- {
- string command = Console.ReadLine();
- switch (command)
- {
- case "/displayall":
- ekwipunek.DisplayItems();
- Console.WriteLine();
- break;
- case "/add":
- string item = Console.ReadLine(); ;
- ekwipunek.AddItem(item);
- Console.WriteLine("{0} has been added to your inventory", item);
- break;
- case "/switch":
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment