Exemplo n.º 1
0
        public CItemInventory Copy()
        {
            CItemInventory out_ = new CItemInventory();

            out_.Count = Count;
            out_.Id    = Id;
            return(out_);
        }
Exemplo n.º 2
0
 public bool ExistItem(CItemInventory itemInventory)
 {
     for (int i = 0; i < Items.Count; i++)
     {
         if (Items[i].Id == itemInventory.Id)
         {
             if (Items[i].Count >= itemInventory.Count)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     return(false);
 }
Exemplo n.º 3
0
            public void AddItem(CItemInventory itemInventory)
            {
                bool f = true;

                for (int i = 0; i < Items.Count; i++)
                {
                    if (Items[i].Id == itemInventory.Id)
                    {
                        Items[i].Count += 1;
                        f = false;
                        break;
                    }
                }

                if (f)
                {
                    Items.Add(itemInventory.Copy());
                }
            }
Exemplo n.º 4
0
 public void DeleteItem(CItemInventory itemInventory)
 {
     for (int i = 0; i < Items.Count; i++)
     {
         if (Items[i].Id == itemInventory.Id)
         {
             Items[i].Count -= itemInventory.Count;
             if (Items[i].Count == 0)
             {
                 for (int j = i; j < Items.Count - 1; j++)
                 {
                     Items[j] = Items[j + 1];
                 }
                 Items.RemoveAt(Items.Count - 1);
             }
             break;
         }
     }
     throw new Exception("Item don't exist");
 }
Exemplo n.º 5
0
 public bool CanAddItem(CItemInventory itemInventory)
 {
     return(true);
 }