ICS 21 / CSE 21 Summer 2012
Lab 3: Smileys at the Races


Purpose

This assignment asks you to write a program in which smileys run a race and computes statistics about their running times. You'll get practice with simple uses of ArrayLists, and additional practice with boolean expressions, if statements, loops, and nested structures.


Program behavior and general requirements

This programs begins with smiley racers lined up along the left edge of the graphics display, facing right; we see them in profile. They each have a name displayed, in color, in the middle of their faces, so we can root for our favorite.

The race begins when the user presses the Go! button; the racers then begin moving to the right. When they hit the right wall, they've completed a lap. (You'll see the number of laps completed by each smiley next to its name.) They reverse direction, so that they're facing left, and their speed is adjusted as discussed below; they then head for the left wall. When a racer hits the left wall, again, the profile and direction are reversed, the speed is adjusted, and the racer heads for the right wall; another lap has been completed.

When a racer completes the race — the is, runs the number of laps that constitute a race — the smiley stops. When all racers finish the race, an area near the bottom of the window shows statistics:

Just above the statistics is a title introducing them.

The program then stops, though the window remains open so that the user can read the statistics. The user clicks on the close box to close the window and end the program; if the close box is clicked while the race is still running, it still shuts down the program.


Technical details

For this assignment, we've again helped you get started by providing a significant amount of code and lots of comments and documentation. All of your work will be done in the SmileyAnimation and SmileyRacer classes. We've provided several classes in compiled form; three of them (SmileyFace, SmileyFacePart, and SmileyDisplay) have public methods and constants that you may need, so we've included text files describing each of them. (Note that SmileyFace and SmileyFacePart as the same as they were in Lab Assignment 2.)

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

Some additional technical details:


Some hints and tips

Do not change any public method signatures or constants. It's also best if you do not change any of the private information, either; that way, you won't have to rethink your work when you take the lab exam.

You can add private fields, constants, and methods to "help" the methods we provided.

You should not need to import any libraries, but you may do so if they are needed to complete your work.

Remember to test your program incrementally, as described in Lab Assignment 2 (and as we talked about in class); it will very likely save you a lot of time and frustration.


About Lab Exam 3

Lab Exam 3 will be very similar, but perhaps not identical, to the program you have been asked to write for this exercise. The lab exam will ask you to implement one or more of the following methods from the SmileyAnimation or SmileyRacer classes: