Lecture Notes on 05 Aug 2013 class Point { // attributes private double x; private double y; // default constructor public Point () { x = 0.0; y = 0.0; } // non-default constructor public Point (double x, double y) { this.x = x; this.y = y; } // accessors public double getX () { return this.x; } public double getY () { return this.y; } // mutators public void setX (double x) { this.x = x; } public void setY (double y) { this.y = y; } // other methods // distance to another Point public double distance (Point p) { return Math.sqrt ((this.x - p.x) * (this.x - p.x) + (this.y - p.y) * (this.y - p.y)); } // string representation of a point public String toString () { String s = "(" + x + ", " + y + ")"; return s; } public boolean equals (Point p) { double delta = 1.0e-18; return (Math.abs(this.x - p.x) < delta) && (Math.abs(this.y - p.y) < delta); } } public class Geometry { public static void main (String[] args) { Point p = new Point (); Point q = new Point (3, 4); System.out.println (p.distance(q)); System.out.println (q.distance(p)); System.out.println (p); System.out.println (q); } }