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