If you do not rethink what you have, it will only get get more tangled as you add more to it. The validate function should only validate the input and take a string as an argument, you can also add a flag for a condition to a switch that will do something depending on if it is supposed to be for one of the four choices you have.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
void validateInput(string input.c_str(), int type)
{
switch(type)
{
case 1:
// Validate players
if(valid)
// Call next function
elseif(keyword)
// Restart
else
// Wrong input
break;
case 2:
...
...
}
}
I don't think you understand what I meant, I didn't mean choices as in an input of 1, 2, 3, 4 gets you a result, I meant, that is a single play through program, that has four points where it asks for user input, that is, the program starts and it asks how many players, its then asks you to name the players, it then asks you to input score for each bowl on each frame, it then asks if you want to play again.
type is not meant to be the input, the string is. type represents the four possible types of input you have:
1 How Many players
2 The Names of the players
3 How many pins did (player) knock down [in the way you've coded it, it asks after every frame is complete]
4 would you like to replay
My one function is meant to replaces and combine all your separate functions. instead of calling a specific function, all you do is add type to the argument. 1 = how many payers, 2 = player name, etc.. You can convert the string to int, char, or whatever inside the case if you need to, but it can be handled with the string in most cases. Any time you need to validate input, you just include the type to the argument list and if you ever add another input, all you have to do is add another case instead of writing one or two more functions. You could validate first, but since you are dealing with multiple types, I feel it is better to do that on a case-by-case basis.
If the numbers are confusing you, think of it this way:
I just really don't understand how that would work and I'm handing this in in several hours so I can't see me changing it, I'm spending my time now making the code neater and cutting out unnecessary code.
I find it hard to believe you are taking a class that requires splitting up the code into multiple classes before you have been taught anything about structure. My solution was far from ideal, but it was the best i could think of w/out completely rewriting you program or making more of a mess of it.
The class is not all that focused on the program, it is more about the project management, I've had a year out of coding in anything but HTML, I'm surprised I remembered how to declare an integer. Plus a lot of the code is not mine.
Project management should still include program structure. Nothing personal, but that project was managed poorly if it let it get so tangled up. If the class is not about the code and more about theory, it should not have any code to begin with. Maybe I missed that part in my class because I chose to use COTS instead of writing my own code?