// CSE 142 // Blueprint for creating objects of type Point public class Point { // fields (state) int x; // each Point object has its own x and y int y; // instance methods (behavior) // moves x and y coordinates of this point by specified amount public void translate(int dx, int dy) { x += dx; y += dy; } // draws this point at its (x,y) position public void draw(Graphics pen) { pen.fillOval(x, y, 3, 3); pen.drawString("(" + x + ", " + y + ")", x, y); } // returns the distance this point is from the origin public double distanceFromOrigin() { return Math.sqrt(x * x + y + y); } }