This lab assignment gives you some practice in basic Java programming by asking you to implement the "smiley faces" example we've been discussing in class.
You are required to pair program for this assignment.
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 fully test all the public SmileyFace methods and with drawing one, two and three faces.
The program's 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.
The user clicks on the close box to close the window and stop the program.
Obtain the workspace: Be sure that you have downloaded the ICS 45J 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.
Download the project, and integrate it into the workspace:
Code it up: 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.
For this first, introductory assignment, we've provided the "high level" design for you, having figured out the classes we should have and their public methods. Do not change these classes definitions or the signatures of these methods— other parts of the program (like the graphics routines and other code wriitten, or to be written, by others) may well depend upon these definitions, and changing them could break the program. However, you are free to, and should, provide any required or useful private components (fields, methods, constants, whatever) to have the program meet all its requirements and exhibit good style.
We have also provided, through object files (in the lib folder) the graphics routines needed to draw smiley faces in the graphics window. The main() method calls another method that calls these routines after the smiley group has been built. So for this assignment, there is no need to worry about drawing the smileys; that happens "automatically" though code we've provided.
As we progress through the assignments, more and more of the high-level (and detailed) design of the program will be left up to you: programming includes many skills beyond just implementing method bodies!
In the provided code are lots of comments describing what the parts of the program do (or should do, once you've completed them) and what code you are to provide. As you work on your program, be sure to modify the comments as needed to reflect a completed program (and, of course, to add your own, additional ones as needed). For example, there are some comments in some classes that say what fields you need to have. Once you have provided the code for those fields, that comment no longer applies and should be removed; instead, you should have brief comments describing what each field holds.
We require you to do this as a matter of course in all assignments from here on out, so we won't specifically mention this in subsequent assignment write-ups.
Have your progam display three distinct (non-overlapping) smiley faces, each with 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. Call each of the public methods in SmileyFace and SmileyFacePart at least once. (The SmileyFacePart calls are made indirectly via calls to methods inherited by the Eye, Face and Mouth classes.)
Zip up your workspace folder into the file SmileyFaces.zip, and turn it in via Checkmate.