


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



CIS 3020, Fall 2002 Programming Assignment 7 Group Project
WORTH: 80
Due by 11:00 PM, December 8, 2002
OBJECTIVE:
To learn how to use arrays, use loops, and read input.
DESCRIPTION:
In this assignment you write a program that scores bowling games.
A game consists of ten frames. Each frame consists of two attempts ("rolls") to knock down a set of ten pins.
A "strike" is when you knock down all ten pins on the first roll of a frame. A "spare" is when you do not get all the pins on the first roll, but knock down any remaining pins on your second roll.
If, after two rolls, there are still pins standing, the score for that frame equals the previous score, plus 1 point for each pin that was knocked down. If you get a spare, the score for the frame is equal to the previous score, plus ten, plus 1 point for each pin you knock down on your next roll (therefore you can't calculate the score until you've finish the first roll of the next frame). Similarly, a strike gives you the previous score, plus ten, plus 1 point for each pin you knock down on your next two rolls.
The tenth frame is handled slightly different than the other nine. If you get a spare, you get a third roll, since the value of the spare depends on the next roll. For the same reason, a strike on the tenth frame gives you two additional rolls.
The program must read input from a file. The file contains some number of lines. Each line consists of a series of numbers, separated by spaces, indicating the number of pins knocked down for each roll of the game. Each line therefore represents one game, and the file can contain data for any number of games.
The program outputs the complete scorecard for each game in the input file.
Each of the first nine frames must be printed as follows:
+-+-+ |a|b| | c | +---+
a: Number of pins knocked down on first roll. Unless all 10 were knocked down (strike), in which case "a" is left blank. The strike mark will be made in "b".
b: Number of pins knocked down on second roll. If all remaining pins were knocked down with the second roll, indicate a spare with "/". If all pins were knocked down on the first roll, indicate a strike with "X".
c: Total score after this frame is played.
A "gutter-ball" is when a roll does not knock down any pins. This is indicated by a "-" in the appropriate space.
The following are examples of a first frame:
+-+-+ +-+-+ +-+-+ +-+-+ +-+-+ |2|5| |8|/| | |X| |-|6| |-|-| | 7 | | | | | | 6 | | - | +---+ +---+ +---+ +---+ +---+
The second and third examples do not have a total score at this point, because we need to know the results of future frames before we can fill in the value.
Since the 10th frame can have an additional roll, it should be drawn slightly different:
+-+-+-+ |a|b|c| | d | +-----+
a: Number of pins knocked down on the first roll, or "X" if a strike. If it's a strike, then the player has 2 additional rolls and a full set of ten pins are put down for the next roll.
b: Number of pins knocked down on the second roll. If all of the pins are knocked down, and "a" was a strike, then "b" is also a strike. If all the pins are knocked down, but "a" was not a strike, "b" is marked as a spare. In either case where all pins are knocked down, a final full set of ten pins are put down for the third roll.
c: Number of pins knocked down on the third roll. This will only be played if "a" is a strike or if "b" is a spare. If all the pins are knocked down, and "b" was a spare (or strike), this is marked as a strike. If all the pins are knocked down, but "b" was neither a spare nor a strike, it is marked a spare.
The following are examples of a tenth frame (all assume that the score after the ninth frame was 200, and that the ninth frame did not end in a strike or a spare):
+-+-+-+ +-+-+-+ +-+-+-+ +-+-+-+ +-+-+-+ +-+-+-+ |8|1| | |8|/|5| |8|/|X| |X|4|5| |X|X|5| |X|X|X| | 209 | | 215 | | 220 | | 219 | | 225 | | 230 | +-----+ +-----+ +-----+ +-----+ +-----+ +-----+
Note that if you get a strike on the first roll of the tenth frame, the two bonus rolls are worth a maximum of 20 extra points. A second strike (for "b") is worth 10 points -- the number of pins you knock down on the third roll does not change the value of "b".
In all cases, the score for each frame should be centered in the space available. If the score cannot be perfectly centered, one extra space should appear to the left of the score. See the sample input / output below for an example of this behavior.
Print a blank line after each scorecard.
In solving this problem, each group should designate one member as a recorder. It is the responsibility of the recorder to submit the group's solution before the required due date and time. The recorded is also responsible for bringing all paper materials that are to be submitted to the final review.
Each group is required to submit one copy of the following material:
You are required to submit electronically:
You are required to turn in on paper:
SUBMISSION INSTRUCTIONS:
To submit your program you should use the turnin commands as you did on the previous assignments. For example, if you created two classes, Bowling.java and BowlingDemo.java , you would first jar these files:
jar -cvf pa7.jar Bowling.java BowlingDemo.java
Then, you submit these files by giving the following command when logged in to your CIS 3020 account (remember to submit these from sand.cise.ufl.edu):
turnin -c cis3020fa02 -p PA7 pa7.jar
GRADING:
50% of your grade will be based on your analysis, design, and implementation. The other 50% will be based on the responses given by one randomly selected member of your group to questions posed about your solution by the Teaching Assistant in your assignment review. It is the responsibility of all members of the group to be familiar with the complete implementation. This includes all details of the analysis, design, and implementation of all code that was submitted -- regardless of whether this selected individual wrote the code that is discussed. The TA might additionally ask the selected individual to use the developed methods to solve some other problem. It is the responsibility of all group members to make sure that everyone is prepared.
All groups must sign up for a review session with a TA. These reviews will occur between Monday, 12/9, and Friday, 12/13. The signup lists will be provided online. These review sessions will last about 15 minutes and be in CSE 429. All group members must be present for the review. Any members not present will receive a maximum of 50% on the assignment.