// A Point is an immutable point in the plane.
// For a much fancier class, see book/Point2D.java

public class Point
{
    // These fields cannot be modified.
    public final double x, y;   // Cartesian coordinates

    // Create a Point
    public Point(double x, double y) { this.x = x; this.y = y; }

    // Euclidean distance between two points
    public double distanceTo(Point that) {
        return Math.hypot(this.x - that.x, this.y - that.y);
    }

    // draw this point
    public void draw() { StdDraw.point(x, y); }

    // draw a line between two points
    public void drawTo(Point that) {
        StdDraw.line(this.x, this.y, that.x, that.y);
    }

    // string representation
    public String toString() { return "(" + x + ", " + y + ")"; }
}
