QuestionQuestion

Programming Problem
You are asked to implement an application which records the bowling scores for bowling game using Test-Driven approach. You only need to record the score for one player. Your program should work properly for all the cases.
The simple requirements for bowling application are described as follows:
To write an application that keeps track of a bowling league. It needs to record the run-time score for the game of one player, with following simple bowling rules:
• Bowling is played on a lane with at the end 10 pins that the player should knock down with a ball that he throws and makes roll on the lane.
• The placing of the ten pins makes up what we call a frame.
• The object of the game is to knock down as many pins as the player can.
•A game is scored on a single line on the score sheet. The line is divided into 10 boxes or "frames".
• Scoring of the game proceeds from left to right, with the running total of pins knocked down noted in each frame.
• Counts of pins knocked down in each frame are also noted in the upper portion of the frame. In each frame, the player can knock down at most 10 pins.
• The player starts bowling each frame with all 10 pins standing. The player has two "throws" with which to knock down all 10 pins for the current frame.
• If the player knocks down all the pins on the first throw, it's called a "strike". The number of pins knocked down with the next two throws is added as "bonus" points for this frame.
• If the player knocks down all the pins on the second throw, it's called a "spare". The number of pins knocked down with the next throw will be added as "bonus" points for this frame.
• If the player does not knock down all 10 pins in a frame with two throws, the number of pins knocked down is added to the running total, which is marked in the frame.
• This counting may demand to play one or two extra throws to complete the score of the 10th frame (one extra throw in case of spare and two in case of strike). Extra throws means extra frames (two if the 10th frame is strike and the first extra throw is a strike to).
Hand in
For the assignment, you have to hand in an electronic copy of the source and testing result.
Remarks: You only need to handle one player for this application, and no interface is required.
Requirements
Test cases
1. perfect game with all strike, total score is 300
2. simple game with all throw with 3 pins down, total score is 60
3. simple game with one spare (4/6) in the middle, and others are 3 pins down, total score is 67
4. simple game with two continued spares (4/6) in the middle and others are 3 pins down, total score is 75
5. simple game with one strike in the middle and others are 3 pins down, total score is 70
6. simple game with two continued strikes in the middle and others are 3 pins down, total score is 87
7. simple game with one spare in the tenth frame, bonus is 10, and others are 3 pins down, total score is 70 (tenth frame is 10, then 3, then 3)
8. simple game with one strike in the tenth frame, each bonus is 10 and others are 3 pins down, total score is 84
9. a game with all spare (3/7) total score is 130
Test wrong input
1. with 15 for one throw
2. with two throws in the same frame bigger than 10
3. with letter input
Running total calculation
Documentation
1. command line and output documentation
2. Code documentation
Design if you are using OO

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

package com.bowlingaasigment;



public class Main {


public static void main(String[] args) {

int total = 0;

BowlingGame match1 = new BowlingGame();
match1.roll(3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3);
System.out.println("the score for first game "+match1.score());

BowlingGame match2 = new BowlingGame();
match2.roll(10,10,10,10,10,10,10,10,10,10,10,10);
System.out.println("the score for second game "+match2.score());


BowlingGame match3 = new BowlingGame();
match3.roll(3,3,3,3,3,3,3,3,4,6,3,3,3,3,3,3, 3,3, 3,3);
System.out.println("the score for thrid game "+match3.score());

BowlingGame match4 = new BowlingGame();
match4.roll(3,3,3,3,3,3,3,3,4,6,4,6,3,3,3,3, 3,3, 3,3);
System.out.println("the score for fourth game "+match4.score());

BowlingGame match5 = new BowlingGame();
match5.roll(3,3,3,3,3,3,3,3,10,3,3,3,3,3,3, 3,3, 3,3);
System.out.println("the score for fifth game "+match5.score());

BowlingGame match6 = new BowlingGame();
match6.roll(3,3,3,3,3,3,3,3,10,10,3,3,3,3,3, 3,3, 3,3);
System.out.println("the score for sixth game "+match6.score());

BowlingGame match7 = new BowlingGame();
match7.roll(3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,10,3,3);
System.out.println("the score for seventh game "+match7.score());

BowlingGame match8 = new BowlingGame();
match8.roll(3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,10,10,10);
System.out.println("the score for eight game "+match8.score());


BowlingGame match9 = new BowlingGame();
match9.roll(3,7,3,7,3,7,3,7,3,7,3,7,3,7,3,7,3,7,3,7,3);
System.out.println("the score for ninth game "+match9.score());


total = match1.score()+match2.score()+match3.score()+match4.score()+match5.score()+
match6.score()+match7.score()+match8.score()+match9.score();

System.out.println("The total score for these games is "+total);


}
}...
$48.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats