Lab 1 Part 1 Part 1: Create a class that maintains a bowling game. A template for the bowling class and a driver is provided in the Extra Files under Content. You can learn more about the game of bowling at the following site: http://slocums.homestead.com/gamescore.html Here is a site you can use to compute the score of a bowling game: http://www.sportcalculators.com/bowling-score-calculator Notice how the score is updated after each frame. a) First create the BowlingGame class. Objects of this class represent a single game of bowling for a given player. A BowlingGame object should maintain the player’s name, current score and frame, and a count of strikes, spares, and gutter balls, etc. The provided files are already set up with the data members, and methods: constructor, toString, getFrame and getScore for the BowlingGame object. In order to complete the Exercise, the shot method needs to be implemented and tested. The shot method takes an int as a parameter and returns a boolean value depending on whether or not there is another shot available in a given frame. If there is not a shot left, the method will return false. Assume the shot method is only given valid input that holds true to the rules of bowling. For example, if we are in the first frame, the shot method will return true if the first value is a 5 and then return false after the next value for that frame. However, if the first shot of a frame is a 10, then the shot method will return false for the second shot (unless it is the 10th frame). The shot method will maintain the scores for each frame, the count of: strikes, spares, and gutterballs, the frame, and the shot for the frame. Remember, the 10th frame does allow a third shot if there is a strike or spare amongst the first two shots. If a player gets a strike on the first shot of the 10th frame and then a gutter ball, the player still gets a third shot. Keep in mind, you are not keeping track of the actual score frame-by-frame, yet. Part 2 Complete the BowlingGame created in Exercise 1. Now that your shot method is working, you can implement the computeScoreFrame method. This method will tally up the score of the game after each frame. In order to keep the score of the game updated frame-by-frame, you will have to consider the three following special cases as you do so: Case 1 (1 spare before the current frame): throw 1 throw 2 score computation for amount to add to score 2 8 10 2+8=10 6 3 25 6*2+3=15 __________________________________________________ Case 2 (1 strike before the current frame): throw 1 throw 2 score computation for amount to add to score X - 10 X=10 5 4 28 (5+4)*2=18 __________________________________________________ Case 3 (2 strikes before the current frame): throw 1 throw 2 score computation for amount to add to score X - 10 X=10 X - 30 X+X=20 3 4 47 3+(3+4)*2=17 __________________________________________________ Notice that, the current score after the frame is bowled requires knowledge of the previous frames’ scores. That is why we maintain the scores in the shot method. That is why these three cases depend on the previous frame ...
Purchase answer to see full attachment