示例#1
0
        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;
        }
示例#2
0
 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}!");
     }
 }