// Zorah Fung, CSE 142 // This class represents a Point on the cartesian plane public class Point { private int x; private int y; // Note: Special mthod called constructor. Called when client // uses the "new" keyword to construct a new Point object. Notice that // we can have multiple constructors public Point(int x, int y) { this.x = x; this.y = y; } public Point() { x = 0; y = 0; } // Translates this point by the given dx and dy public void translate(int dx, int dy) { x += dx; y += dy; } // Returns this Point's distance from origin public double distanceFromOrigin() { return Math.sqrt(x * x + y * y); } // Returns the String representation of this Point public String toString() { return "(" + x + ", " + y + ")"; } }