Due: Thursday, April 19th at 10:40am
Rules: You may consult your notes, old work, the textbook, examples and sample solutions available at the CS202 web page, and the Java API documentation. You may not consult any other people.
Scoring: There are three problems. Each problem will be graded out of 100 points. The two problems you do best on will each be worth 40% of your grade for the exam. The problem you do worst on will account for the remaining 20%. Keep in mind that it may be more worthwhile for you to move on to a new problem than to spend too much time working out the final details of another.
Files: Files for all problems are in a Java archive.
Submissions: Submit the source code (.java files) for your solutions as attachments to e-mail. You should send five classes total (one each from Problems 1 and 2, and three from Problem 3 (Leyak, Oni, and Mythical).
Problem 0: Plan on attending the Computer Science picnic tomorrow at Oregon Ridge Park starting at 2pm.
Problem 1: Complete the LX_P1 class so it opens a window for a survey tallying program. The interface should look like the one shown below. When the user clicks on the "Yes" button, the count for yes votes should be increased. When the user clicks on the "No" button, the count for no votes should be increased. The most common answer should be displayed with the totals (highest total first). If there are an equal number of yes votes and no votes, "Even x-x" should be displayed. The color of the text should change as the most frequent answer changes: green for yes, red for no, and black for even. The interface should look as much like the one shown below as possible. You should try to avoid repeating code (hint: although I am not requiring a complete model/view/controller setup, moving slightly in that direction may help).
Problem 2: Complete the LX_P2 class so it opens a file called "lx_p2_input.txt" (included in the jar file) that contains results of basketball games for a single team. The program should create an output file called "lx_p2_output.txt" and write one line to the output file for each line of the input file. The input file will look like
54-88 Virginia [17-14, 74.1486] 70-54 Maryland, Baltimore County [6-20, 58.1423] 60-66 Loyola, Chicago [16-14, 64.4321] 80-64 Indiana University/Purdue University Indianapolis [12-19, 67.4722]Each line of the output file should start with "vs. " and then give the name of an opponent, and the sum of the opponents rating and the team's margin of victory (or loss) against that opponent. For example, for the input file given above, the output file should contain
vs. Virginia 40.1486 vs. Maryland, Baltimore County 74.1423 vs. Loyola, Chicago 58.432100000000005 vs. Indiana University/Purdue University Indianapolis 83.4722You may handle exceptions any way you see fit. You should assume that the names of the opponents do not contain brackets.
Problem 3: Fairy checkers is played with pieces with movement and capture rules different from regular checkers. In the version shown below, there are two pieces: Leyaks (blue), and Oni (green). Leyaks move one or two spaces vertically or horizontally. They can jump over any piece. The piece is removed if it is not another Leyak. They can also capture opposing pieces by moving to the same location. Oni can move like Leyaks and can also move one space diagonally. They too can jump pieces, but if the piece is not an Oni it is not removed; instead it is frozen so it can't move. They can also move onto spaces occupied by opposing pieces, but if they do so on a move of more than one space, instead of removing the opposing piece it is moved to where the Oni started its move.
Leyak, and Oni are subclasses of GamePiece. Refactor the Leyak and Oni classes so they are subclasses of a new class called Mythical which is in turn a subclass of GamePiece. Full credit will be given only to solutions that leave only a minimal amount of code in the two subclasses.
To test your code, compile and run GameWindow.