// Zorah Fung, CSE 142 // An example of Polymorphism public class CritterTest { public static void main(String[] args) { Hippo harry = new Hippo(5); // Can also store critters of different types in a variable of type Critter Critter carl = new Cougar(); Critter victor = new Vulture(); // Because Snake, Ant, Bird, Hippo, Vulture and Cougar are all critters, we // can store these in an array of Critters. Critter[] critters = {new Snake(), new Ant(false), new Bird(), harry, carl, victor}; for (int i = 0; i < critters.length; i++) { printMoves(critters[i], 15); } } public static void printMoves(Critter critter, int n) { for (int i = 0; i < n; i++) { System.out.print(critter + " "); System.out.print(critter.getMove() + " "); } System.out.println(); } }