import java.awt.*; class Circle { // make the variables protected, so they can be accessed // directly only by subclasses protected int radius; protected int xCoordinate; protected int yCoordinate; public Circle() { radius = 10; xCoordinate = 15; yCoordinate = 15; } //constructor public Circle(int r, int x, int y) { radius = r; xCoordinate = x; yCoordinate = y; } //constructor public void draw(Graphics g) { g.drawOval(xCoordinate - radius, yCoordinate - radius, 2 * radius, 2 * radius); } // draw public int getRadius() { return radius; } // getRadius public int getXCoordinate() { return xCoordinate; } // getXCoordinate public int getYCoordinate() { return yCoordinate; } // getYCoordinate public double getCircumference() { return Math.PI * 2 * radius; } // getCircumference public double getDiameter() { return 2 * radius; } // getDiameter public double getArea() { return radius * radius * Math.PI; } // getArea } //Circle class ColoredCircle extends Circle { protected Color theColor; public ColoredCircle() { super(); theColor = Color.red; } //constructor public ColoredCircle(int r, int x, int y) { super(r, x, y); theColor = new Color((int)(Math.random() * 156) + 100, (int)(Math.random() * 156) + 100, (int)(Math.random() * 156) + 100); } // constructor public ColoredCircle(int r, int x, int y, Color c) { super(r, x, y); theColor = c; } // constructor public void draw(Graphics g) { // save the color the user was using, so we can set it back Color oldColor = g.getColor(); g.setColor(theColor); g.fillOval(xCoordinate - radius, yCoordinate - radius, 2 * radius, 2 * radius); g.setColor(oldColor); } // draw public Color getColor() { return theColor; } // getColor } // ColoredCircle