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)); } }
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); } }
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; } }
protected override void ValidateFood(Food food) { if (food.GetType().Name != nameof(Meat)) { Throw(food); } }
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; }
protected override void ValidateFood(Food food) { var type = food.GetType().Name; if (type != nameof(Meat) && type != nameof(Vegetable)) { Throw(food); } }
protected override void ValidateFood(Food food) { string type = food.GetType().Name; if (type != nameof(Vegetable) && type != nameof(Fruit)) { Throw(food); } }
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; }
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; }
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; }
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}!"); } }
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}!"); } }
protected void Throw(Food food) { throw new ArgumentException($"{this.GetType().Name} does not eat {food.GetType().Name}!"); }
protected override bool IsFoodValid(Food food) => food.GetType().Name == "Meat" ? true : false;
protected override bool IsFoodValid(Food food) => food.GetType().Name == "Vegetable" || food.GetType().Name == "Fruit" ? true : false;