This lab assignment gives you some practice in basic Java programming by asking you to implement the smiley faces example weve been discussing in class — with a few additional wrinkles.
In general, you are to write a Java program that draws one, two or three smiley faces on the screen, each with characteristics you provide, such as the color and the shape of the face itself, and of the eyes and mouth. You also implement methods that translate (move) the smiley as a whole, and that let you scale and translate each of the smileys parts (the face, eyes and mouth). (Scaling the smiley face as a whole requires some knowledge of linear algebra, so we do not include that feature.)
The SmileyGroup() constructor contains the code that produces the faces. We suggest you write various bodies for SmileyGroup() so that you gain experience in using the two smiley face constructors, the setAttributes() method and the smiley face translation and scaling routines, and with drawing one, two and three faces.
Program behavior is straight-forward: when run, a graphics window and SmileyGroup are created, then SmileyGroup is given to the graphics routines, which draws the one, two or three smiley faces described by that SmileyGroup; the window is then made visible on the screen so that the user actually sees the smiley group. This approach, common in graphics environments, allows the programmer to fully construct a screen before showing it to the user.
Each face you make should have two eyes that are above an imaginary horizontal line through the center of the face, and a mouth that is below that imaginary line; the eyes and mouth should have colors that make them distinguishable from the face. Within these parameters, you may make the faces look however you'd like.
The user clicks on the close box to close the window and stop the program.
Be sure that you have downloaded the ICS 21 Eclipse workspace, and have set it up as described in the Orientation to the Lab section of this manual. Many settings have been changed from Eclipse defaults to appropriately support your work in this course, so be sure that youre using this workspace. That way, not only will things be properly set up for your assignments, but your work will match the environment that youll be using during lab exams.
Download the Eclipse project for this assignment and import it into your workspace:
As you work, Eclipse will compile your program automatically each time you save it. Pay attention to changes in the Problems window, especially errors, because these often indicate things that youve either done incorrectly or things that you need to do to finish the part of the program youre working on.
Lab exam 1 will be similar, but not identical, to the program you are to code for this exercise. In particular, the assignment allows you the freedom to explore different combinations of smiley faces and their attributes; the lab exam instead will be quite specific about the characteristics of the faces you are to draw. Remeber to read INSTRUCTIONS!.txt and program comments before beginning your coding; they will explain in detail what is required. Remember that you must follow the exam specifications completely to pass the exam and that a significant failure to follow class style standards can result in a not pass even if your program is otherwise complete and correct.
The lab exam will have you code one or more of the following methods: