import java.awt.Color; public class ColorPoint { private Color color; private Point point; private class InternalPoint extends Point { InternalPoint(int x, int y) { super(x, y); } public void moveTo(int x, int y) { super.moveTo(x, y); showMove(); } } public ColorPoint(int x, int y, Color color) { point = new InternalPoint(x, y); this.color = color; } public void moveTo(int x, int y) { point.moveTo(x,y); } public int getX() { return point.getX(); } public int getY() { return point.getY(); } private void showMove() { System.out.println("moving to (" + point.getX() + "," + point.getY() + ")"); } // Returns the point-view of this color point. public Point asPoint() { return point; } public boolean equals(Object o) { if (!(o instanceof ColorPoint)) return false; ColorPoint cp = (ColorPoint) o; return cp.point.equals(point) && cp.color == color; } }