Advice for c++ project

Hey guys I'm working on a project for a beginner c++ class where we have to take a line of a bowling score (ex. XXX9/X81XX9/XXX) and output it into the 10 frames (ex. X X X 9/ X 81 X X 9/ XXX). I had no problem with that part but after that we have to score it frame-by-frame and that's the part I'm having a lot of trouble with. If I did it the same way I did the first part (using a for loop and a bunch of if and else if statements) that would obviously take way too much code. I know I have to convert the symbols into integers (X=10, /=10, etc) and I know I need to think of each frame as being 3 balls (for scoring purposes) but I'm not sure how to put all this together and I'm not sure what to do first.

If you're not familiar with how to score a game this website will help:
http://www.bowlingindex.com/instruction/scoring.htm. Obviously I'm not asking anyone to solve this for me, I just need a little guidance... I've only been going at this c++ stuff for a few months now. Thank you in advance for all your help and advice!
You should be able to handle all the frames generically, with a single piece of code (without repeating it 10 times).

Let's assume your input is in a string:

 
std::string line = "XXX9/X81XX9/XXX";


Write one function that returns just the characters relevant to frame N. For example, the characters
relevant to frame 6 are "81", frame 5 is "X81", frame 4 is "9/X", frame 10 is "XXX". Input to this function
is the frame number and the line, output is a portion of line corresponding to the given frame.

Now write a function that scores the frame. Frame 6 is 9; frame 5 is 19; frame 4 is 20; frame 10 is 30.
Input to the function is the return value from the previous function. Output is an (unsigned) integer score.

Now write a third function that takes as input the entire line, and uses the first two functions to score each
frame, adding their individual results together and returning the sum of the 10 frame scores.

Your main function can prompt the user for the line score, read it in, call the third function above and
output the result.
Topic archived. No new replies allowed.