/** Circle.java provides a class to represent Circle objects.
 */
import java.lang.*;
import java.io.*;

class Circle extends Object
{
    // attribues of a circle
    // a circle is defined by the position of its center and its radius
    private double xPos, yPos;      //  position
    private double radius;          // raduis
 
    // ----------------------------------------------------------------
    // constructor -- every circle has a radius and an x and y position
    Circle( double r, double x, double y ) { 
        radius = r;
        xPos = x;
        yPos = y;
    }
    
    // alternate constructor -- you could also define a circle by its
    // center and a point on the circumfrence
    Circle( double xCent, double yCent, double xEdge, double yEdge ) {
        xPos = xCent;
        yPos = yCent;
        radius = Math.sqrt( Math.pow( xCent-xEdge, 2 ) + 
                            Math.pow( yCent-yEdge, 2 ) );
    }
    
    // ----------------------------------------------------------------
    // converters
    // the "toString" converter is used whenever you use a circle in a
    // context where Java wants a String
    public String toString() {
        return "Radius = " +radius+ ", center = ( " +xPos+ ", " +yPos+ " )";
    }

    // 
    
    // ----------------------------------------------------------------
    // setters
    public void setPos( double newX, double newY ) { 
        xPos = newX; yPos = newY;
    }
    
    public void setRad( double newR ) { radius = newR; }
    
    // ----------------------------------------------------------------
    // getters
    public double getX() { return xPos; }
    public double getY() { return yPos; }
    public double getR() { return radius; }
    
    // ----------------------------------------------------------------
    // area of circle
    public double area( ) {
        return Math.PI * radius * radius;
    }
    
    // circumfrence of a circle
    public double circumfrence() {
        return 2 * Math.PI * radius;
    }
    
    // ----------------------------------------------------------------
    // overlap -- do two circles overlap?
    public boolean overlap( Circle other ) {
        // does this circle overlap with  other  ?
        
        double dist = Math.sqrt( Math.pow(xPos-other.xPos, 2) + 
                                 Math.pow(yPos-other.yPos, 2) );        
        return dist < radius + other.radius;
    }
}