Chapter 7, Sierra/Bates, Quiz Question # 6
Which of the following changes (taken separately) would allow this code to compile? (Choose all that apply.)
A. Change the Carnivore interface to
B. Change the Herbivore interface to
C. Change the Sheep class to
D. Change the Sheep class to
E. Change the Wolf class to
F. No changes are necessary
I can understand why B is the answer. However, I cannot understand the explanation for D
And D doesn’t work, because in D we made Sheep extend Plant, now the Wolf class breaks because its munch(Sheep) method no longer fulfills the contract of Carnivore.
How is Wolf class broken?