Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Carnivore extends Animal
- {
- public Carnivore(String newName, int newAge)
- {
- super(newName, newAge);
- }
- public void eat(Food food) throws Exception
- {
- if (food instanceof Meat)
- {
- System.out.println("The carnivore is eating " +food.getFoodName());
- }
- if (food instanceof Plant)
- {
- throw new Exception("IncorrectFoodType");
- }
- }
- }
Add Comment
Please, Sign In to add comment