package shapes; //HappyFace.java //cmc, 11/23/00 import java.awt.*; /** A blue colored happy face drawing. */ public class HappyFace extends FilledCircle { /** Only useful constructor. @param x X coordinate @param y Y coordinate @param d diameter of happy face drawing */ public HappyFace(int x, int y, int d) { super(x, y, d); } /** Draws the happy face on the Graphics parameter. */ public void draw(Graphics g) { int x = x(); int y = y(); int diameter = width(); // same as height for this object //Draw filled blue happy face outline g.setColor(Color.blue); g.fillOval(x, y, diameter, diameter); //Draw yellow eyes g.setColor(Color.yellow); int eyeSize = diameter / 8; int eyeY = y+diameter / 4; int leftEyeX = x + diameter / 2 - diameter / 5; int rightEyeX = leftEyeX + diameter / 3; g.fillOval(leftEyeX, eyeY, eyeSize, eyeSize); g.fillOval(rightEyeX, eyeY, eyeSize, eyeSize); //Draw yellow mouth int mouthSize = (int)(diameter * 0.6); int mouthArcX = x + diameter / 5; int mouthArcY = y + diameter / 5; g.drawArc(mouthArcX, mouthArcY, mouthSize, mouthSize, 0, -180); } }