public override void Feed(Food food)
 {
     if (food.GetType().Name == "Vegetable" || food.GetType().Name == "Meat")
     {
         double totalgain = (double)food.Quantity * WeightGain;
         this.Weight    += totalgain;
         this.FoodEaten += food.Quantity;
     }
     else
     {
         throw new Exception(string.Format(WrongFoodExeption.Exp_Msg, GetType().Name, food.GetType().Name));
     }
 }
예제 #2
0
 public override void Feed(Food food)
 {
     if (food.GetType().Name == "Vegetable" || food.GetType().Name == "Fruit")
     {
         double totalweightgain = Weight_Gain * (double)food.Quantity;
         this.Weight    += totalweightgain;
         this.FoodEaten += food.Quantity;
     }
     else
     {
         string msg = string.Format($"{WrongFoodExeption.Exp_Msg}", GetType().Name, food.GetType().Name);
         throw new Exception(msg);
     }
 }
예제 #3
0
        public virtual void Eat(Food food)
        {
            var foodType = food.GetType().Name;

            if (this.NotEatbleFood.Contains(foodType))
            {
                throw new ArgumentException($"{this.GetType().Name} does not eat {food.GetType().Name}!");
            }
            else
            {
                this.FoodEaten += food.Quantity;
                this.Weight    += food.Quantity * this.WeightModifier;
            }
        }
예제 #4
0
 protected override void ValidateFood(Food food)
 {
     if (food.GetType().Name != nameof(Meat))
     {
         Throw(food);
     }
 }
예제 #5
0
 public override void Eat(Food food)
 {
     if (food.GetType().Name == "Meat")
     {
         throw new ArgumentException("Zebras are not eating that type of food!");
     }
     this.FoodEaten += food.Quantity;
 }
 public virtual void Eat(Food food)
 {
     if (!LikesFood)
     {
         throw new Exception($"{GetType().Name} does not eat {food.GetType().Name}!");
     }
     Weight    += WeightGain * food.Quantity;
     FoodEaten += food.Quantity;
 }
예제 #7
0
        protected override void ValidateFood(Food food)
        {
            var type = food.GetType().Name;

            if (type != nameof(Meat) && type != nameof(Vegetable))
            {
                Throw(food);
            }
        }
예제 #8
0
        protected override void ValidateFood(Food food)
        {
            string type = food.GetType().Name;

            if (type != nameof(Vegetable) && type != nameof(Fruit))
            {
                Throw(food);
            }
        }
예제 #9
0
        public void Feed(Food food)
        {
            if (!foodsEaten.Contains(food.GetType()))
            {
                throw new InvalidOperationException(string.Format(ExceptionMessages.InvalidFoodType, this.GetType().Name, food.GetType().Name));
            }

            this.Weight += food.Quantity * this.FoodMultiplier;
            FoodEaten   += food.Quantity;
        }
예제 #10
0
        public void Eat(Food food)
        {
            if (!Eats(food))
            {
                Console.WriteLine($"{GetType().Name} does not eat {food.GetType().Name}!");
                return;
            }

            FoodEaten += food.Quantity;
            Weight    += WeightIncrease * food.Quantity;
        }
예제 #11
0
 public override void Eat(Food food)
 {
     if (food is Vegetable || food is Fruit)
     {
         base.Eat(food);
         this.Weight += 0.1 * food.Quantity;
     }
     else
     {
         throw new ArgumentException($"Mouse does not eat {food.GetType().Name}!");
     }
 }
        protected void BaseEat(Food 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;
        }
예제 #13
0
 public override void Eat(Food food)
 {
     if (food is Meat)
     {
         base.Eat(food);
         this.Weight += 0.4 * food.Quantity;
     }
     else
     {
         throw new ArgumentException($"Dog does not eat {food.GetType().Name}!");
     }
 }
예제 #14
0
 public override void EatFood(Food food)
 {
     if (food is Meat)
     {
         this.Weight    += food.Quantity * foodIncrease;
         this.FoodEaten += food.Quantity;
     }
     else
     {
         throw new ArgumentException($"{GetType().Name} does not eat {food.GetType().Name}!");
     }
 }
예제 #15
0
 protected void Throw(Food food)
 {
     throw new ArgumentException($"{this.GetType().Name} does not eat {food.GetType().Name}!");
 }
예제 #16
0
 protected override bool IsFoodValid(Food food) => food.GetType().Name == "Meat" ? true : false;
예제 #17
0
 protected override bool IsFoodValid(Food food) => food.GetType().Name == "Vegetable" || food.GetType().Name == "Fruit" ? true : false;