private void AddItem(string[] inputParams) { Character characterToAcceptIitem = this.GetCharacterById(inputParams[1]); Item itemToAdd; switch (inputParams[2].ToLower()) { case "axe": itemToAdd = new Axe(inputParams[3]); characterToAcceptIitem.AddToInventory(itemToAdd); break; case "shield": itemToAdd = new Shield(inputParams[3]); characterToAcceptIitem.AddToInventory(itemToAdd); break; case "pill": itemToAdd = new Pill(inputParams[3]); characterToAcceptIitem.AddToInventory(itemToAdd); break; case "injection": itemToAdd = new Injection(inputParams[3]); characterToAcceptIitem.AddToInventory(itemToAdd); break; default: break; } }
protected new void AddItem(string[] inputParams) { Item item; Character character = characterList.Where(x => x.Id == inputParams[1]).FirstOrDefault(); string itemName = inputParams[2]; string id = inputParams[3]; switch (itemName) { case "axe": item = new Axe(itemName); break; case "shield": item = new Shield(itemName); break; case "injection": item = new Injection(itemName); break; case "pill": default: item = new Pill(itemName); break; } character.AddToInventory(item); }