public class Reptile extends Animal{ private static int number_of_legs; public Reptile(String name, int age, int weight, boolean poisonous, int number_of_legs){ super(name, age, weight, poisonous); this.number_of_legs = number_of_legs; } public int compareTo(Object o){ try{ if(this.number_of_legs == ((Reptile)o).number_of_legs) return 0; else if(this.number_of_legs > ((Reptile)o).number_of_legs) return 1; else return -1; }catch(Exception e){ //if the comparison fails, then we //assume both are not Reptiles and //must be compared in the superclass Animal return super.compareTo(o); } } public String toString(){ return super.toString() + "\nnum_legs: " + number_of_legs; } }