// A very simple class that defines a cartesian point, and has a translate // method and a constructor public class Point { int x; // an "instance variable" defining the point's x value int y; // an "instance variable" defining the point's y value // a constructor method for a Point object public Point(int x, int y) { this.x = x; this.y = y; } public Point(int x) { this.x = x; } public Point() { } // this method translates the point by (dx, dy) public void translate(int dx, int dy) { this.x += dx; // "this" is a reference to the object instance this.y += dy; // whose translate method was invoked } }