Smiley Face Crowd       CPS 004.1, 9 July 2003

You are to write a Java applet that draws several copies of the Smiley face you created in the previous assignments, in different locations and at different sizes to create the effect of a smiling crowd. Each should have the same color and same parts in the same relative position, but in a different location and with different proportions.

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

Specifications

Instead of copying the code in your applet's constructor that creates a Smiley Face and manually changing each new set of variable names, you should make a separate Smiley face class so that Java will keep track of that information for you. When you make a Smiley face class, each time one is created using new, Java will create a separate copy of the variables in that object and keep track of changes to them distinct from those in other instances of the class. In other words, each class tells Java what properties to create, but then Java maintains different instances of those variables.

You will update the code in your applet to make your Smiley face a class of its own, separate from the applet class. In Visual J++, do this by selecting Add Class from the Project menu and giving the new class a more meaningful name than Class1. Then move the code from your applet into your new class, so there is nothing being done in the applet and everything is done in the new class. Finally, add code in the applet to create as many distinct Smiley face objects as you want.

In order to be able to put the Smiley faces in different positions so they are not all stacked on top of each other, you will need to be able to allow the applet to set the position and size of each separately. So, instead of locking those values away inside the Smiley Face object, you should allow the applet to pass those values to the Smiley face when it creates it, using parameters.

An example can be seen online here. A worked out example can be seen online here.

What to Submit

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.