// "MovingHappyFaceClass.java" - The MovingHappyFaceClass class

import java.awt.*;

public class MovingHappyFaceClass extends HappyFaceClass
{
    // Additional fields of the class
    int dx, dy;
    int width, height;
    
    public MovingHappyFaceClass (int width, int height)
    {
	this (100, 100, width, height);
    } // MovingHappyFaceClass constructor


    public MovingHappyFaceClass (int x, int y, int width, int height)
    {
	super (x, y);
	radius = (int) (Math.random () * 75 + 25);
	dx = (int) (Math.random () * 11 - 5);
	dy = (int) (Math.random () * 11 - 5);
	this.width = width;
	this.height = height;
    } // MovingHappyFaceClass constructor
    
    
    public void slide (Graphics g, Color bgColour)
    {
	if ((x + dx < radius) || (x + dx > width - radius))
	{
	    dx = -dx;
	}
	if ((y + dy < radius) || (y + dy > height - radius))
	{
	    dy = -dy;
	}
	move (x + dx, y + dy,g, bgColour);
    } // slide method    
} // MovingHappyFaceClass class
