Beispiel #1
0
 public void TryToFeed(Food currentFood)
 {
     if (this.FoodType.Contains(currentFood.GetType()))
     {
         this.FoodEaten += currentFood.Quantity;
         this.Weight    += currentFood.Quantity * IncreaseWeightForEveryPiece;
     }
     else
     {
         Console.WriteLine($"{this.GetType().Name} does not eat {currentFood.GetType().Name}!");
     }
 }
Beispiel #2
0
        public override void Eat(Food food)
        {
            if (food.GetType() != typeof(Vegetable))
            {
                throw new ArgumentException($"{this.GetType().Name}s are not eating that type of food!");
            }

            this.FoodEaten += food.Quantity;
        }
Beispiel #3
0
        public override void CheckFoodType(Food food)
        {
            var typeFood = food.GetType().Name;

            if (typeFood != "Meat")
            {
                throw new ArgumentException($"{this.GetType().Name} does not eat {typeFood}!");
            }
            base.CheckFoodType(food);
            IncreaseAnimalWeight(food);
        }
Beispiel #4
0
 public override void Eat(Food food)
 {
     if (food.GetType().Name == "Vegetable")
     {
         this.QuantityEatenFood += food.Quantity;
     }
     else
     {
         Console.WriteLine($"{this.GetType().Name} are not eating that type of food!");
     }
 }
        public override void Eat(Food food)
        {
            Console.WriteLine(Mouse.Sound);

            string foodType = food.GetType().Name;

            if (foodType == "Vegetable" || foodType == "Fruit")
            {
                this.IncreaseWeight(Mouse.WeightUp, food);
            }
            else
            {
                Console.WriteLine($"{this.GetType().Name} does not eat {foodType}!");
            }
        }
Beispiel #6
0
        public override void Eat(Food food)
        {
            Console.WriteLine(Tiger.Sound);

            string foodType = food.GetType().Name;

            if (foodType == "Meat")
            {
                this.IncreaseWeight(Tiger.WeightUp, food);
            }
            else
            {
                Console.WriteLine($"{this.GetType().Name} does not eat {foodType}!");
            }
        }