public int compareTo(Object rhs){ // Compares rhs object with this object // Precondition: The object rhs should be a Sphere object // Postcondition: If this sphere has the same radius as the // rhs sphere, returns zero. If this sphere has a larger // radius the rhs sphere, a positive integer is returned. If // this sphere has a smaller radius than the rhs sphere, a // negative integer is returned. // Throws: ClassCastException if the rhs object is not a // Sphere object. // Throws ClassCastException if rhs cannot be cast to Sphere Sphere other = (Sphere)rhs; if (theRadius == other.theRadius) { return 0; //Equal } else if (theRadius < other.theRadius) { return -1; } else { // theRadius > other.theRadius return 1; } } // end compareTo