Generic Smiley Face       CPS 004.1, 8 July 2003

You are to write a Java applet that draws the same Smiley face you created in the previous assignment, but in a different location and at a different size. You will update the code in your applet to make your Smiley Face as general as possible so that when anyone asks you to reposition or resize your Smiley Face anywhere within the applet, you can do it easily and immediately instead of redoing the painstaking work it took to determine the exact coordinates the first time.

This exercise is meant to familiarize you with the following concepts discussed in class and your reading:

Specifications

Rather than simply recalculating the sizes and positions on paper of all the shapes that make up your Smiley face, and then typing those numbers literally into your applet; you should use some basic arithmetic to tell the computer to recalculate the values for you. Then, the question is how many numbers do you need someone to enter before you know how to correctly position and size your Smiley face. To make the job of someone using your program as simple as possible, you will do all your calculations based solely on the center position and size of the oval that makes up the head of the Smiley face.

Using variables of type double, which represent real numbers, you should determine the relationship between the positions and sizes of all of the parts of your Smiley face and the center point and size of the head. You should do all of this in the constructor for the Applet class.

You should test your code by first trying the Smiley Face in exactly the same position and size you started with. If that does not match, then you have definitely done something wrong! Once you have that working, you should stress test your program by trying to put your Smiley Face in all four quadrants and the extreme areas of the applet at both large and small sizes.

A worked out example can be seen online here.

What to hand in

You should start a new project for this exercise. You should feel free to copy your code from the previous exercise, but you will be making many changes. Additionally, we will want to look at this exercise separately from your previous Smiley face.

When you are finished, you and your partner should transfer the entire project folder created by Visual J++ to your respective public_html/cps4 folder in the acpub system and update your course web page to link to the newly transferred project using the guidelines given here.