2629881

itemsCount

Aug 2nd, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. public class Inventory
  2.     {
  3.         string[] arrayItems = new string[6];
  4.         int itemsCount = 0;
  5.         public void AddItem(string item)
  6.         {
  7.             if (itemsCount >= 6)
  8.             {
  9.                 Console.WriteLine("Inventory full");
  10.             }
  11.             else
  12.             {
  13.                 arrayItems[Array.IndexOf(arrayItems, null)] = item;
  14.                 itemsCount++;
  15.                 Console.WriteLine("{0} has been added to your inventory. Number of items:{1}", item, itemsCount);
  16.             }
  17.         }
Advertisement
Add Comment
Please, Sign In to add comment