public class Cat extends Pet { // properties inherited from the Pet (parent/base) class: // // name, birthYear // properties specific to Cats: private int numLives; // methods inherited from Object class: /** * Returns a String representation of this cat * @return ... */ public String toString() { String str = name + ": " + birthYear + ", " + numLives; return str; } /** * Checks if this cat is identcial to the given object. * @param ... * @return ... */ public boolean equals(Object other) { if (this == other) { // 1. is the other one me? return true; } else if ( !(other instanceof Cat) ) { // 2. is the other one a different kind? return false; } else { // 3. the other one is not me, but is a Cat Cat otherCat = (Cat) other; // turn the Object into a Cat if ( name.equals(otherCat.getName()) && birthYear == otherCat.getBirthYear() && numLives == otherCat.getLives() ) { return true; } else { return false; } } } }