// Allison Obourn, CSE 142 // Blueprint for creating objects of type Point import java.awt.*; public class Point { int x; int y; // Creates a Point with the provided x and y // coordinates public Point(int newX, int newY) { x = newX; y = newY; } // Creates a Point with x and y coordinates // set to the origin public Point() { x = 0; y = 0; } // Draws a point as a dot with a coordinate label // with the provided Graphics g public void draw(Graphics g) { g.fillOval(x, y, 3, 3); g.drawString("(" + x + ", " + y + ")", x, y); } // Moves the Point's x and y by a provided dx and // dy amount public void translate(int dx, int dy) { x = x + dx; y = y + dy; } // Returns the distance of the Point from (0, 0) public double distanceFromOrigin() { return Math.sqrt(x * x + y * y); } // Sets the location of the Point to the passed in // x and y values public void setLocation(int x, int y) { this.x = x; this.y = y; } }