CompSci 6
Spring 2009
Program Design and Analysis

Drawing a Smiley Face

The origin of the bright yellow smiley face is not completely clear. The earliest known examples of the graphic are attributed to Harvey Ball, who devised the face in 1963 for a Worcester, Massachusetts, USA-based insurance firm, State Mutual Life Assurance. Ball never attempted to use, promote, or trademark the image and it fell into the public domain in the United States before that could be accomplished. It rose to popularily in the seventies and was recently given the rare honor of appearing on a postage stamp, becoming the spokesperson for Wal-mart, and, of course, a representation of our emotions during text-based conversations as emoticons.


Write a Java program that draws a Smiley Face using the Java's Graphics class that represent shapes and their attributes. Your program should draw the correct shapes, in the correct order, to draw a Smiley Face with at least a head, two eyes, and a smile that is centered in the Canvas and whose head is half as big as the window, no matter what size the window is.

Since the position and size of the shapes you draw will not be fixed, they should be computed based on the current size and center of the Canvas. To get started, complete the problem Proportion and test your solution using the testing page within your browser.

After completing this problem, change the paint method of the Canvas class so that it draws your smiley face. Using Java's Graphics class, you can draw the following shapes: oval, rectangle, line, text, and arc. Creativite extras for your smiley face (e.g., a hat, nose, teeth, headband, etc.) will be rewarded with extra credit. Here are some examples from previous semesters.

For even more extra credit, create a new method, drawSmiley, that takes a Point, center, and a Dimension, size, and draws a smiley centered at the given point whose face is the given size (i.e., the size does not have to include your extras). You should then replace the code in the paint method of the Canvas class with multiple calls to your drawSmiley method with different locations and different sizes to create some recognizable pattern (e.g., a line, a star, or an x). Each should have the same color and same parts in the same relative position, but in a different location and with different proportions.

Submitting your work Electronically

When you are satisfied you have completed the both the Proportion problem and the Smiley Face described above, you should electronically submit your project through Eclipse. A submission is not considered complete unless it includes all the Java code for the project (both what you have written and the code provided when you downloaded the project) and a README file as described here.