public CItemInventory Copy() { CItemInventory out_ = new CItemInventory(); out_.Count = Count; out_.Id = Id; return(out_); }
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); }
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()); } }
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"); }
public bool CanAddItem(CItemInventory itemInventory) { return(true); }