Project P3

Calculating bowling match scores


A bowling match consists of ten frames. Each frame except for the tenth consists of one or two balls, or attempts to knock down the ten pins at the end of the alley. Doing so on the first ball of the frame is called a strike, and the second ball of the frame is not rolled. Knocking down all ten pins with both balls (having left some up with the first ball) is called a spare. If both attempts to knock down the pins leave some standing, the frame is called an open frame. A spare in the tenth frame gives the bowler one extra ball; a strike in the tenth gives him or her two extra balls. A bowling score is computed as follows. A strike counts as 10 points plus the sum of the next two balls. A spare counts as 10 points plus the next ball. Any other balls merely count as themselves, as do any bonus balls rolled as a result of a strike or a spare in the tenth frame.

Example

Suppose for example that the sequence of balls was

9 1   0 10   10   10   6 2   7 3   8 2   10   9 0   9 1   10

The cumulative score for the ten frames would be

1
2
3
4
5
6
7
8
9
10
10
30
56
74
82
100
120
139
148
168


Problem Requirements

Write a program that can calculate the cumulative scores for the ten frames given the scores for a sequence of balls.

You must follow this Java class definition:

public class BowlingScores
{
    /**
     * Calculate the cumulative frame scores given the scores for
     * a sequence of balls.
     *
     * @param  ballScores  blank delimited String of ball scores.
     *         The scores are whole numbers separated by one or more blanks.
     * @pre    The number of scores is valid for one game.
     * @return   List of ten frame scores, in order.
     */
    public static List<Integer> calculate(String ballScores)

You may assume that the input data is valid.

Illustrative method call:

String data = "1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1";
System.out.println(BowlingScores.calculate(data));
would output: [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]

Note: Please design your own solution. While this algorithm is easy to find on the Web or in textbooks, please write your own algorithm from scratch.

Unit Testing

You must submit execution output that demonstrates that your program can produce the correct results for data in the Example above.  This output can be created in one of two ways:

Perform any additional tests you want to convince yourself that your solution is correct.

Acceptance Testing

In addition, your program must pass the instructor's acceptance test.  Once you are satisfied that your program is correct and is passing your unit tests, create a new time log entry.  Enter "Test" for the phase and in the comment field enter "Acceptance Testing".

Submit your source code using the Web-CAT grader. On this project the grader will not run your own unit tests. Web-CAT will report checkstyle errors in red and they WILL count in your total score. Each coding standard violation is a defect. The defect type is 10 for code syntax, and 80 for Javadoc errors. (Tip: To avoid getting style errors in Web-CAT, run the Checkstyle extension in BlueJ before submitting to Web-CAT.)

If Web-CAT reports any errors, tally them in a new section of the defect tally without an inject phase, with a removal phase of "ACCEPTANCE TEST".  Don't add them to Injected Phase or total on the Summary form. You are allowed five Web-CAT submissions without penalty.  If you take more than five submissions, your project earns only half-credit.

When Web-CAT assigns a 100% score to your work, you should finalize your work according to the assignment directions.