Example #1
0
        public override void IsFoodAppropriate(Food.Food food)
        {
            var type = food.GetType().Name;

            if (type == "Vegetable" || type == "Meat")
            {
                this.EatFood(food.Quantity);
            }
            else
            {
                throw new ArgumentException($"{this.GetType().Name} does not eat {food.GetType().Name}!");
            }
        }
Example #2
0
 protected override void ValidateFood(Food.Food food)
 {
     if (food.GetType().Name != nameof(Meat))
     {
         this.Throw(food);
     }
 }
Example #3
0
        protected override void ValidateFood(Food.Food food)
        {
            string type = food.GetType().Name;

            if (type != nameof(Meat))
            {
                Throw(food);
            }
        }
Example #4
0
        protected override void ValidateFood(Food.Food food)
        {
            string type = food.GetType().Name;

            if (type != nameof(Vegetable) && type != nameof(Fruit))
            {
                Throw(food);
            }
        }
Example #5
0
        public void Feed(Food.Food food)
        {
            if (!this.PrefferedFoods.Contains(food.GetType()))
            {
                throw new InvalidOperationException($"{this.GetType().Name} does not eat {food.GetType().Name}!");
            }

            this.FoodEaten += food.Quantity;
            this.Weight    += food.Quantity * this.WeightAddOnMultiplier;
        }
Example #6
0
 public override void Eat(Food.Food food)
 {
     if (food.GetType().Name == "Vegatable")
     {
         Console.WriteLine("Tigers are not eating that type of food!");
     }
     else
     {
         base.FoodEaten = food.Quantity;
     }
 }
Example #7
0
        public virtual void eatFood(Food.Food food)
        {
            if (this.GetType().Name == "Zebra" || this.GetType().Name == "Mouse")
            {
                if (food.GetType().Name != "Vegetable")
                {
                    Console.WriteLine($"{this.GetType().Name}s are not eating that type of food!");
                    return;
                }
            }
            else if (this.GetType().Name == "Tiger")
            {
                if (food.GetType().Name == "Vegetable")
                {
                    Console.WriteLine($"{this.GetType().Name}s are not eating that type of food!");
                    return;
                }
            }

            this.FoodEaten += food.Quantity;
        }
Example #8
0
 protected void Throw(Food.Food food)
 {
     throw new ArgumentException($"{this.GetType().Name} does not eat {food.GetType().Name}!");
 }