示例#1
0
        public void TryEatFood(Foods food)
        {
            Type typeofFood = food.GetType();

            if (!PreferredFoods.Contains(food.GetType()))
            {
                throw new InvalidOperationException($"{GetType().Name} does not eat {typeofFood.Name}!");
            }

            FoodEaten += food.Quantity;
            Weight    += food.Quantity * WeightIncreaseMultiplier;
        }
示例#2
0
        protected void BaseEat(Foods food, List <string> eatableFood, double gainValue)
        {
            string typeFood = food.GetType().Name;

            if (!eatableFood.Contains(typeFood))
            {
                throw new ArgumentException($"{this.GetType().Name} does not eat {typeFood}!");
            }

            this.Weight    += food.Quantity * gainValue;
            this.FoodEaten += food.Quantity;
        }