private void CheckItemNull(BackpackItem item) { if (item == null) { throw new NullReferenceException("Not valid item!"); } }
public void updateItem(BackpackItem item) { CheckItemNull(item); if (items.ContainsKey(item.ItemName)) { items.Remove(item.ItemName); items.Add(item.ItemName, item); } }
public void addItem(Item item, int count) { BackpackItem backpackItem = new BackpackItem(); backpackItem.Item = item; if (backpackRepository.contains(item.ItemName)) { backpackItem.increaseCount(count); backpackRepository.updateItem(backpackItem); } else { backpackItem.Count = count; backpackRepository.addItem(backpackItem); } }
public void addItem(BackpackItem item) { CheckItemNull(item); items.Add(item.ItemName, item); }