11. Animal

Animal and CarnivoreAnimal.

The Animal is an abstract class with the following methods:

  • int beEaten(): returns the number of calories provided
  • void gainCalories (int amount): increases number of calories.

When you construct an Animal, the constructor needs to know how many calories are in the animal.

CarnivoreAnimal is a concrete subclass of Animal. It also has a method void eat(Animal other). This method causes the CarnivoreAnimal to gain the calories provided by the other Animal (found using the beEaten() method).

Last modified August 18, 2023: 2022-2023 End State (7352e87)