// "HappyFace.java" - The HappyFace module

import java.awt.*;

public class HappyFace
{
    // The fields of the object
    static int x = 100, y = 100;
    public static int radius = 50;
    static Color clr = Color.blue;
    static boolean showing = false;
    
    // Paint the happy face onto the screen. The paint method
    // is not part of the interface.
    static 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.
    static 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 static void show (Graphics g)
    {
    	paint (g);
    	showing = true;
    } // show method
    
    // Hide the happy face  The hide method is part of the interface.
    public static 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 static 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   
} // HappyFace class    
    
