// Represents a shape.
abstract class Picture {

    // Reports if this is the same picture as the input.
    abstract boolean samePicture( Picture input );

    // Reports if this is the same circle as the input.
    boolean sameCircle( Circle input ) {
        // In the general case, this is not a circle.
        return false;
    }

    // Reports if this is the same rectangle as the input.
    boolean sameRectangle( Rectangle input ) {
        // In the general case, this is not a rectangle.
        return false;
    }

    // Reports if this is the same text as the input.
    boolean sameText( Text input ) {
        // In the general case, this is not text.
        return false;
    }
}

// Represents a circle.
class Circle extends Picture {
    double radius;

    Circle( double radius ) {
        this.radius = radius;
    }

    // Reports if this is the same picture as the input.
    boolean samePicture( Picture input ) {
        input.sameCircle( this );
    }

    // Reports if this is the same circle as the input.
    boolean sameCircle( Circle input ) {
        return Math.abs( this.radius - input.radius ) < 0.01;
    }
}

// Represents a rectangle.
class Rectangle extends Picture {
    int width;
    int height;

    Rectangle( int width, int height ) {
        this.width = width;
        this.height = height;
    }

    // Reports if this is the same picture as the input.
    boolean samePicture( Picture input ) {
        return input.sameRectangle( this );
    }

    // Reports if this is the same rectangle as the input.
    boolean sameRectangle( Rectangle input ) {
        return
            (this.width == input.width) &&
            (this.height == input.height);
    }
}

// Represents a line.
class Text extends Picture {
    String message;

    Text( String message ) {
        this.message = message;
    }

    // Reports if this is the same picture as the input.
    boolean samePicture( Picture input ) {
        return input.sameText( this );
    }

    // Reports if this is the same text as the input.
    boolean sameText( Text input ) {
        return this.message.equals( input.message );
    }
}


