Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The class hierarchy is starting to shape up. We have each subclass override the makeNoise() and eat() methods, so that there’s no mistaking a Dog bark from a Cat meow (quite insulting to both parties). And a Hippo won’t eat like a Lion.
But perhaps there’s more we can do. We have to look at the subclasses of Animal, and see if two or more can be grouped together in some way, and given code that’s common to only that new group. Wolf and Dog have similarities. So do Lion, Tiger, and Cat.
Look for more opportunities to use abstraction, by finding two or more subclasses that might need common behavior.
We look at our classes and see that Wolf and Dog might have some behavior in common, and the same goes for Lion, Tiger, and Cat.