Skip to content

Commit c7c7e2f

Browse files
committed
Stating that Carnivorous eats Herbivorous and Herbivorous eats Plants
1 parent 09f5369 commit c7c7e2f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/main/java/Carnivorous.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ public boolean eat(BoardMovement sth) {
1414
throw new IllegalArgumentException("Carnivorous animals can only eat other animals");
1515
}
1616
}
17+
18+
@Override
19+
public boolean canEat(BoardMovement sth) {
20+
return sth instanceof Herbivorous;
21+
}
1722
}

src/main/java/Herbivorous.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,9 @@ public boolean eat(BoardMovement sth) {
1414
throw new IllegalArgumentException("Herbivorous animals can only eat plants");
1515
}
1616
}
17+
18+
@Override
19+
public boolean canEat(BoardMovement sth) {
20+
return sth instanceof Plant;
21+
}
1722
}

0 commit comments

Comments
 (0)