// CSE 142, Autumn 2010, Marty Stepp // This class defines a new type of objects named Point. // Each Point object represents one (x, y) location. // Point objects contain a bit of behavior (methods) as well; // they know how to print their coordinates and how to draw themselves. import java.awt.*; // for Graphics public class Point { int x; // each Point object has its own copy int y; // of each of these variables (fields) // EACH Point object gets its own copy of the method, // the method knows which object you called it on, // and it can directly access the data (fields) in that object by name. public void hello() { System.out.println("my coordinates are " + x + ", " + y); } // Draws this point using the given graphics pen. public void draw(Graphics g) { g.fillOval(x, y, 3, 3); g.drawString("(" + x + ", " + y + ")", x, y); } }