Smileys at the Races

Lab Assignment 3
to prepare for Lab Exam 3

This assignment has you write a program that has smileys run a simple lap race and computes statistics about their running times. The assignment gives you practice with simple uses of ArrayLists, and additional practice with boolean expressions, if statments, loops and nested structures


Program behavior and general requirements

This program begins with smiley racers, on 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; these racers then begin moving to the right. When they hit the right wall, they’ve completed a lap. They reverse direction, their profiles face left, their speed is adjusted as discussed below, and they 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; that is, runs the number of laps that constitue a race, the smiley stops. When all racers finish the race, the fastest time and the name of the racer with that time, the slowest time and the racer with that time, and the average racer time, along with a title introducing these statistics, appear in the small window at the bottom of the “race track.” The program then stops; the window remains open so 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 your work is done in the SmileyAnimation and SmileyRacer classes. We provide several already-written class files; one of these, SmileyFace, has several public methods and constants you may need to employ, so we included the text file SmileyFace.txt describing those public items. (They are the same as in Assignment 2; we are reusing the SmileyFace class yet again, saving you a lot of work!)

You also use one method from the SmileyDisplay class—repaint()—which works just as it did in Assignment 2, and one public constant from that class, SmileyDisplay.BACKGROUND_COLOR. (Since we need just these two simple-to-use items, we’ve not included a SmileyDisplay.txt documentation file for this assignment.)

These files are stored together in the archive file Lab3.zip. Download Lab3.zip to your computer and unzip it into its own folder. Replace all spaces marked // your code goes here with your own Java code so that a complete, correctly working program results.

Some additional technical details: