コード例 #1
0
 public override void Eat(Food food)
 {
     if (food.GetType().Name == "Meat")
     {
         this.FoodEaten += food.Quantity;
     }
     else
     {
         Console.WriteLine($"{this.GetType().Name}s are not eating that type of food!");
     }
 }
コード例 #2
0
 public override void Eat(Food food)
 {
     if (food.GetType().Name == "Vegetable")
     {
         this.FoodEaten += food.Quantity;
         Console.WriteLine("A cheese was just eaten!");
     }
     else
     {
         Console.WriteLine($"{this.GetType().Name}s are not eating that type of food!");
     }
 }