ICS 21 / CSE 21 Summer 2012
Lab 2: Animated Smiley


Purpose

This assignment gives you some more practice in basic Java programming, including practice with "if" statements and simple loops, by enhancing the previous Smiley program to handle animation of a smiley face as it moves and interacts with the walls (boundaries) of the graphics window.


Reminder: Find yourself a new partner!

We're requiring you to work with a different partner on each assignment, so don't forget to find a new partner before you proceed with this assignment.


Program behavior and general requirements

In general, you are to complete the Java class SmileyAnimation, which we've added to the Smiley program so that smiley faces can be animated.

A completed version of this program will work in the following way:


Technical details

For this assignment, we've again helped you get started by providing some code and lots of comments and documentation. All of your work is to be done in the SmileyAnimation class. We've provided several already-written classes (in compiled form) that provide functions that you will likely need to use in your program. Three of these in particular — SmileyFace, SmileyFacePart, and SmileyDisplay — have public methods you may need to employ, so we've included text files — SmileyFace.txt, SmileyFacePart.txt, and SmileyDisplay.txt — describing those public methods. You may be surprised that SmileyFace and SmileyFacePart are not provided in source code form, since you wrote them in the last assignment. But that is exactly the point: having written and thoroughly tested them, we can now use their methods to make and manipulate smiley face characteristics without paying attention to the classes' details; we don't need the source to use the classes' capabilities.

These files have been collected into an Eclipse project and zipped into an archive called 21Lab2.zip. Using the same procedure that you followed in the last assignment, import this project into your Eclipse workspace.


Testing tips

It's typically fastest to implement and debug a program when it is done in stages; when something goes wrong, you know it was because of changes made at the current stage, thus reducing the amount of code you have to search to find the mistake. Testing in stages can take many forms. For this assignment, since all of the methods you are writing are in one class, testing in stages boils down to adding and testing a method or two at a time, judiciously choosing them so that, as you add them, you are incrementally heading to a completed program.

For an example, here's an outline of one way to incrementally implement and test your program:


About Lab Exam 2

Lab Exam 2 will be very similar, but perhaps not identical, to the program you are being asked to write for this assignment. The lab exam will ask you to implement one or more of the following methods from the SmileyAnimation class: