CS 51 Test Program #1
Due: Friday, October 15, 2010, at 6 PM
Complete each of the following problems, documenting your code well. Starters for all three problems can be found in the TP1 folder in the same spot where you get the starters for your lab assignments.
You are encouraged to reuse the code from your labs or our class examples. Submit your code in the usual way by exporting and dragging it into the dropbox folder. Please do not submit three separate folders. Instead, place the folders for all three of your complete programs into one folder (which should be named lastname-TP1, so if I were submitting this my folder would be named Kauchak-TP1), make sure that your name appears not only in the main folder but also in each of the subfolders, and then place the main folder in the CS51 dropoff folder.
Note that if you do everything that's required, the maximum number of points you can get is 96. In order to get the full 100, you must implement some extra features. We've provided some ideas below, but you should feel free to exercise your creativity.
A running version of the program should be visible below if your browser handles applets correctly:
Extra credit ideas: time how long the user takes to make it through the track, setup a more complicated maze for the user to navigate, use better graphics for the track, circle and target.
For this problem you will be implementing a rising, splitting ball. When the program begins, the screen is empty except for a horizontal line. If the user clicks above this line, nothing happens. If the user clicks below this line, a new ball with diameter 20 is created that then proceeds to rise with a random speed towards the vertical line. When it hits the line, it splits into two smaller balls, each of which have 3/4s the diameter of the original ball and those two parts then proceed horizontally in opposite directions at the same speed the original ball had along below the horizontal line. Recall that inside a run method you can have more than one while loop and that they can be sequential (i.e. not nested).
You will need to include two classes: the SplitterController class, which extends WindowController and handles the mouse events and a SplittingBall class that extends ActiveObject which handles the animation of a splitting ball.
The size of the screen should be 400 by 400 and the start file includes relevant constants.
A running version of the program should be visible below if your browser handles applets correctly. You'll have to hit the refresh button on the browser to reset the game.
Set is a simple card game designed in the 1970s that tests players' ability to identify sets of 3 cards that are either the same or all-different along four dimensions: shape, number, color and shading (see http://www.setgame.com/). We're going to implement a simplified version of this game.
Our set cards will consist of rectangles with only two features. The rectangles can have differing heights (1, 2 and 3 times the base height) or differing colors (red, green or blue). The program will start with three SetCards being displayed on the screen next to each other in a 200 by 200 window. The user clicks if he/she thinks it is a set. In our case, we'll use a very simplified version of a set where the features need to be differing, that is, all the sizes are different and all of the colors are different. For example, the figure on the left below is a set while the figure on the right is not since the first two have the same size.
You should implement two classes, a SetGame class that extends WindowController and a SetCard class representing the cards. Your SetCard class should contain a method called reset that chooses another random configuration for that card. Notice that this means when the user requests a "new" set of cards, you shouldn't actually create a new set of cards, instead you should pick a new random configuration for each of the cards.
A running version of the program should be visible below if your browser handles applets correctly:
Value | Feature |
Style (16 pts for each of 3 programs) | |
2 pts. | Use of boolean conditions |
2 pts. | Ifs/whiles |
2 pts. | Appropriate variable (instance/local, public/private) |
2 pts. | Descriptive comments |
2 pts. | Good names |
2 pts. | Good use of constants |
2 pts. | Appropriate formatting |
2 pts. | Parameters used appropriately |
Correctness (16 pts for each of 3 programs) | |
Race Track | |
2 pts. | Initial screen drawn correctly |
3 pts. | Circle is dragged appropriately |
4 pts. | Circle correctly detects and resets to wall touches |
4 pts. | Winning is detected and message displayed |
3 pts. | Game and text resets appropriately |
Splitting Hairs | |
1 pts | Initial screen drawn correctly |
4 pts | balls create where clicked and move up |
2 pts | balls can't be created above line |
5 pts | balls split appropriately |
2 pts | random ball speeds |
2 pts | balls are removed appropriately when finished |
Set | |
5 pts | Initial cards/screen drawn correctly |
4 pts | game resets appropriately |
4 pts | correct/incorrect are detected appropriately |
3 pts | not recreating cards |
Miscellaneous (4 pts total) | |
Extra Credit (4 pts maximum) | |