Charlie Suwankosai
Bowling Analysis
main.cpp
This main function calls the three main functions PromptPlayer, PlayMatch, and Stats. PromptPlayer asks the user to enter the bowler's name and their skill level that will be used later to skew the dice. The information is stored in a vector. Then the function PlayMatch takes these players and goes through an entire 10 frames of a bowling game. The last function, Stats, compares the scores of each of the players and figures out which bowler had the highest score. Stats also prints out each player's name and how many "marks" and "strikes" they had.
The Bowler class rolls a dice that determines how many pins are knocked down per throw. The dice rolls twice unless the first roll produces a 10. The dice is also skewed by the level of the bowler. The frame and game class keep track of the game and the scores throughout the game.
1. If there were going to be two bowlers in one game, then the bowlers would have to take turns. Where as if there was only one bowler bowling many games, then the program would go through one entire game before starting another.
2. The function Bowler::TakeTurn goes through one turn. It rolls the dice once. If the roll is less then 10 then the dice rolls again. Each time the dice rolls the number is printed.
The function is never called in the program so it doesn't really do anything.
3. The frame class keeps track of how many pins are knocked down in each frame.
4. The vector object in the class Frame makes it easy to keep track of how many pins are knocked down in each frame. The information can be accessed easier this way.
5. In frame.cpp the MAX_ROLLS_PER_FRAME count is 3. The only time that three rolls are allowed per frame is the 10th frame. In the function Game::TakeTurn() there is an extra if statement that only passes once the 10th frame is reached.
6. It updates the previous pin counts after a mark since the next roll (or two) needs to be counted with the previous frame.
7. The rolls are all printed as they are rolled. Then the score is tabulated at the end.
Critique
The biggest problem that I had about the code was the part about the skewed bowling for bowlers with the higher skill level. I understand that some bowlers are better than others and that is why there is a reason behind the skill level. But the way that this program uses that number and their explanation for it is throughly confusing.
Some of the names were poorly chosen. The function TakeTurn can be part of two different classes. I think that one should be named one thing and the other one should be named something completely different so that it wouldn't be as confusing.
1. Some of the comments were actually helpful, but for the most part the comments were extremely confusing. For example, in the function Bowler::TakeTurn there is a comment that reads "Dice rolls 1-11. So we'll change this to 0 - 10. " What in the world does that mean? Once again I get the idea behind it, but I don't exactly see where it happens. Then later in the function Bowler::Roll it has a nice paragraph about how the dice is supposed to be "skewed" for bowlers with higher skill levels. The comments I think confused me more.
2. I don't think that the PlayMatch function is long at all code wise. It has a nested for loop so it might take a while to go through it, but the coding is not long at all.
The function Stats could be broken up a little bit. It could be broken up into two parts I think. The first part would find the highest score and the winner of the match. And then print it out The second part would tally up everyone's marks and strikes and print out the totals.
The function Game::TakeTurn could also be broken up into a few parts. It could be broken up into three functions and each function would be responsible for one roll of the ball.
3. If the functions IsMark, NumSpares, and NumStrikes were added to the code then counting the number of marks and strikes at the end would be a lot easier since there would be a running total going on.
4. The purpose of the skill level idea is to give the bowlers with the higher skill level a better score than the bowlers with the lower skill levels. It makes sense but I don't think it is carried out properly.
5. The program should work as intended. You could test it out by running a few bowlers and then checking their scores by hand to make sire everything was added the way it should.