// "HappyFaceClass.java" - The HappyFaceClass class

import java.awt.*;

public class HappyFaceClass
{
    // The fields of the class
    int x = 100, y = 100;
    int radius = 50;
    Color clr = Color.blue;
    boolean showing = false;

    public HappyFaceClass ()
    {
    } // HappyFaceClass constructor


    public HappyFaceClass (int x, int y)
    {
	this.x = x;
	this.y = y;
    } // HappyFaceClass constructor


    // Paint the happy face onto the screen. The paint method
    // is not part of the interface.
    void paint (Graphics g)
    {
	g.setColor (clr);
	g.drawOval (x - radius, y - radius, 2 * radius, 2 * radius);
	g.drawOval (x - radius / 5 - 5, y - 2 * radius / 5 - 5, 10, 10);
	g.drawOval (x + radius / 5 - 5, y - 2 * radius / 5 - 5, 10, 10);
	g.drawArc (x - 4 * radius / 5, y - 4 * radius / 5,
		8 * radius / 5, 8 * radius / 5, 180, 180);
    } // paint method


    // Erase the happy face from the screen. The erase method
    // is not part of the interface.
    void erase (Graphics g, Color backgroundColor)
    {
	g.setColor (backgroundColor);
	g.drawOval (x - radius, y - radius, 2 * radius, 2 * radius);
	g.drawOval (x - radius / 5 - 5, y - 2 * radius / 5 - 5, 10, 10);
	g.drawOval (x + radius / 5 - 5, y - 2 * radius / 5 - 5, 10, 10);
	g.drawArc (x - 4 * radius / 5, y - 4 * radius / 5,
		8 * radius / 5, 8 * radius / 5, 180, 180);
    } // erase method


    // Show the happy face. The show method is part of the interface.
    public void show (Graphics g)
    {
	paint (g);
	showing = true;
    } // show method


    // Hide the happy face  The hide method is part of the interface.
    public void hide (Graphics g, Color backgroundColor)
    {
	erase (g, backgroundColor);
	showing = false;
    } // hide method


    // Move the happy face from one location to another. The move method
    // is part of the interface.
    public void move (int newX, int newY, Graphics g, Color backgroundColor)
    {
	if (showing)
	{
	    erase (g, backgroundColor);
	}
	x = newX;
	y = newY;
	if (showing)
	{
	    show (g);
	}
    } // move method
} // HappyFaceClass class

