/* mPoint.java */ import java.awt.*; public class mPoint { int x, y; Color color = Color.black; public mPoint(int _x, int _y) { /* initial location */ x = _x; y = _y; } public void setColor(Color _color) { color = _color;} public void setColor(Graphics g, Color _color) { if ( _color == color ) return; paint(g); /* use XOR to hide object */ color = _color; paint(g); /* draw object on new location */ } /* check if position inside object */ public boolean isInside(int _x, int _y) { return (x == _x) && (y == _y); } /* move object */ public void moveTo(Graphics g, int _x, int _y) { if ( (x == _x) && (y == _y) ) return; paint(g); /* use XOR to hide object */ x = _x; /* update location */ y = _y; paint(g); /* draw object on new location */ } public void move(Graphics g, int dx, int dy) { if ( (dx == 0) && (dy == 0) ) return; paint(g); /* use XOR to hide object */ x += dx; /* update location */ y += dy; paint(g); /* draw object on new location */ } public void paint(Graphics g) {} }