1 // Fig. 7.8: Point.java 2 // Definition of class Point 3 4 public class Point { 5 protected double x, y; // coordinates of the Point 6 7 // constructor 8 public Point( double a, double b ) { setPoint( a, b ); } 9 10 // Set x and y coordinates of Point 11 public void setPoint( double a, double b ) 12 { 13 x = a; 14 y = b; 15 } 16 17 // get x coordinate 18 public double getX() { return x; } 19 20 // get y coordinate 21 public double getY() { return y; } 22 23 // conver the point into a String representation 24 public String toString() 25 { return "[" + x + ", " + y + "]"; } 26 }