public void Eat(Food food) { if (!EatenFoods.Contains(food.GetType().Name) && EatenFoods.Count != 0) { throw new ArgumentException($"{GetType().Name} does not eat {food.GetType().Name}!"); } FoodEaten += food.Quantity; Weight += food.Quantity * WeightIncrease; }
public void Eat(Food food) { if (EatenFoods.Contains(food.GetType().Name)) { FoodEaten += food.Quantity; } else { throw new InvalidOperationException($"{this.GetType().Name} does not eat { food.GetType().Name}!"); } }