There is no special in-lab exercise this week. Your AI will be answering your questions on your problems with other labs, going over posted solutions on various labs and how your solutions could be improved or rewritten.
This week's lab assignment will not be treated as a separate assignment. If you submit this assignment, it will be counted as bonus credits on top of lab 6. Note that lab 6 is due by March 12, 1999. You have until March 23 only for the bonus part.
In this exercise you will turn your darts program into a two player game. Run this demo for a working version of the program.
Notice that the darts (and the scores) for the two different players are drawn in two different colors. At the end of the game, a message is printed indicating who won, or if the game was a tie.
So, you will need to keep track of and display two scores. There are also a total of six darts being thrown, three in each color. Modify your throwDart function so that it takes an additional int argument, player, which indicates whose turn it is. If player is 1, then it is Player 1's turn, otherwise it is Player 2's turn. Modify the body of this function so that the prompt for readMouse gives the player number and so that the dart is drawn in the right color.
Save your program in a file named DartGame.java.
For the Ambitious: This is not part of the basic assignment, so students can certainly earn a grade of B on this lab without doing this part. This is for those students who want to guarantee that they get an A, or who are trying for an A+.
After you have completed your two player game, then modify the scoring so that ties are broken by declaring the winner to be the player who comes closest to the center of the bullseye. That is, a score of 50 + 25 + 0 beats a score of 25 + 25 + 25 even though they both sum to 75. Furthermore, a score of 50 + 25 + 25 beats a score of 50 + 25 + 25 if the first player's 50 is closer to the center than the second player's 50.
There can still be a tie if both players have the same total scores and their closest darts are the same distance from the bullseye center. (You can try breaking that tie by comparing the second closest darts and, if need be, the third closest. This is quite difficult to implement, and is way beyond the call of duty.)
The important thing here is to get practice writing functions. So, don't clutter up your run function with lots of tie-breaking details.
Any code that you write to implement this tie-breaking algorithm will not be considered unless your basic DartGame program works correctly according to the specifications.
For this lab, you should submit one file: DartGame.java. Attach this file to an e-mail sent to a201@cs.indiana.edu with lab6a as the subject.