This assignment gives you some more practice in basic Java programming, including practice with if statments and simple loops, by enhancing the previous Smiley program to handle animation of a smiley face as it interacts with the walls (boundaries) of the graphics window.
You are to complete the Java class SmileyAnimation, which weve added to the Smiley program so that smiley faces can be animated.
When you run a (correctly) implemented version of this program, a graphics window appears, with a smiley face in it; the exact shape and color of the face are up to you, within the bounds that the face must be small enough that it can move around within the graphics window and be recognizable as a smiley face. That smiley heads off towards a wall, an edge of the graphics window. When it hits the wall it should
This behavior continues for a number of milliseconds, set as a constant in the program; every time the smiley hits a wall, it and the wall swap colors and the smiley rebounds, heading to another wall.
Closing the window ends the program, even if the window is closed while the smiley is still moving.
For this assignment, weve 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 SmileyAmination class. We provide several already-written classes, in compiled form, that provide functions you will likely need to use in your program. Three of these, SmileyFace, SmileyFacePart, and SmileyDisplay, have public methods you may need to employ, so we included text files, SmileyFace.txt, SmileyFacePart.txt, and SmileyDisplay.txt, that describe those methods. You may be surprised that SmileyFace and SmileyFacePart are not provided in source code form, since you wrote those classes 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 characterisics without paying attention to the class details; we dont need the source to use the class 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.
Its 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 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 example, heres an outline of one way to incrementally implement and test your program:
Lab exam 2 will be very similar, but perhaps not identical, to the program you are to code for this assignment. You will implement one or more of the following methods (all are from the SmileyAnimation class):
Remember to read over INSTRUCTIONS!.txt and program comments before beginning; they will tell you what you are to complete and give any particulars (such as, for example, the characteristics of a smiley face you are to draw or the kind of movement it should exhibit when animated).