Advertisement
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 inventory
- {
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace inventory
- {
- public class Inventory
- {
- string[] arrayItems = new string[6];
- public void AddItem(string item)
- {
- for (int i = 0; i < arrayItems.Length; i++)
- {
- if (arrayItems[i] == null)
- {
- arrayItems[i] = item;
- return;
- }
- }
- Console.WriteLine("{0} has been added to your inventory", item);
- }
- public void DisplayItems()
- {
- Console.WriteLine("Your items are:");
- foreach (string item in arrayItems)
- {
- Console.Write(item + ";");
- }
- Console.WriteLine();
- }
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- Inventory inventory = new Inventory();
- //Console.WriteLine("Wpisz komende /add /switch /display.");
- //Console.WriteLine();
- // test
- inventory.DisplayItems();
- //Console.WriteLine();
- inventory.AddItem("DUPA");
- inventory.AddItem("BISKUPA");
- //Console.WriteLine();
- inventory.DisplayItems();
- // test
- //while (true)
- //{
- // string command = Console.ReadLine();
- // switch (command)
- // {
- // case "/display":
- // inventory.DisplayItems();
- // Console.WriteLine();
- // break;
- // case "/add":
- // string item = Console.ReadLine(); ;
- // inventory.AddItem(item);
- // break;
- // case "/switch":
- // break;
- // }
- //}
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement