/** Instances are animals with name and age */ public class Animal { private String name; // Cannot be empty. private int age; // Must be >= 0 /** Constructor: instance of animal with name, age * Precondition: n not null, empty * age >= 0 */ public Animal(String n, int a) { name = n; age = a; } public Animal() { } /** Yields Animal name */ public String getName() { return name; } /** Yields Animal age */ public int getAge() { return age; } /** Yields: "a is older than this animal" */ public boolean isOlder(Animal a) { return a.age > age; } /** Yields: String representation of this object */ public String toString() { return name+" (Animal, age "+age+")"; } /** Yields: Òh is an Animal with the same * values in its fields as this Animal */ public boolean equals(Object h) { if (!(h instanceof Animal)) { return false; } Animal ob= (Animal)h; return name.equals(ob.name) && age == ob.age; } public static double checkWght(Animal h) { Cat c = (Cat)h; // Downward cast return c.getWeight(); } }