// "Exer2a.java" - Exercise on Classes
//
// Modify this program to simultaneously slides three happy faces from the
// left side of the screen to the right side.
// Assume the radius of the happy face is 50.  Use applet's getSize ()
// to determine the applet's height and width.

// Modified September 16, 2007
// Philip P

import java.applet.*;
import java.awt.*;

public class Exer2a  extends Applet 
{
	// Use constant radius declared here since the "radius"
	// in the HappyFaceClass is not static
	//static final int defaultRadius = HappyFaceClass.radius;
	static final int defaultRadius = 50;
	
    public void paint (Graphics g)
    {
		HappyFaceClass face1, face2, face3;
		int width = getSize ().width;
		int height = getSize ().height;
		
		int xPosition = defaultRadius;
		
		// Show three happy faces at the starting x-position (edge of applet)
		face1 = new HappyFaceClass (xPosition, 100);
		face1.show (g);          // Show the happy face
		face2 = new HappyFaceClass (xPosition, 200);
		face2.show (g);          // Show the happy face
		face3 = new HappyFaceClass (xPosition, 300);
		face3.show (g);          // Show the happy face
		
		// Move the happy faces to the other side
		while (xPosition < (this.getWidth() - defaultRadius)) {
			xPosition++;
			face1.move(xPosition, face1.y, g, this.getBackground());
			face2.move(xPosition, face2.y, g, this.getBackground());
			face3.move(xPosition, face3.y, g, this.getBackground());
		}
    
    } // paint method
    
    
} // Exer2a class
