// "Exer1a.java" - Exercise on Objects
//
// Modify this program to move the happy face to each corner of the screen.
// Start the face in the lower-left corner and have it move to the upper-left 
// then upper-right then lower-right and then back to lower-left corner.
// Assume the radius of the happy face is 50.  Use applet's getSize ()
// to determine the applet's height and width.

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

public class Exer1a extends Applet
{
    public void paint (Graphics g)
    {
		final int radius = HappyFace.radius; 
    	int width = getSize ().width;
		int height = getSize ().height;
		
		HappyFace.show (g); // Show the happy face
		
		// Move the face to all four corners
		// Loop it twice
		for (int i = 0; i < 3; i++) {
			moveFace(radius, height-radius, g);
			moveFace(radius, radius, g);
			moveFace(width-radius, radius, g);
			moveFace(width-radius, height-radius, g);
		}
	
    }
    
    public void moveFace (int x, int y, Graphics graphic) {
    	try { Thread.sleep (500); }    // Wait half a second
    	catch (InterruptedException e) { ; }
    	HappyFace.move (x, y, graphic, getBackground ()); // Move the happy face
    }
} // Exer1a class