Hi masters!
I have a problem with my while loop.
I realised that my code does not work the way I want.
It has to check if sum of def, mid and att variables is different from 10 or if style variable is different from multiple strings. So if any of them does not meet the requirement, repeat the code in {} .
My style condition which is repeated is interfering with other style conditions.
So my question is - How to write this while loop (or it doesn't have to be while) to give me the thing I want?
Is there any way to write it like:
while(style!={"contain","defensive","counter"}){
//do something
}
Here is the code:
char znak; // just takes "-" in the line like this: 4-4-2
string style = "standard"; // default style
cout << "--- MATCH PREPARATION ---" << endl;
cout << "Choose formation (like 4-4-2): "; cin >> def >> znak >> mid >> znak >> fwd;
cout << endl;
cout << "Choose style (contain,defensive,counter,standard,control,attacking,overload): " << endl;
cin >> style;
cout << endl;
/////////Problematic while loop////////////////////
while((def+mid+fwd)!=10 || style!="contain" || style!="defensive" || style!="counter" || style!="standard" || style!="control" || style!="attacking" || style!="overload")
{
cout << "Unknown style or formation! Please check your spelling..." << endl;
cout << "Choose formation (like 4-4-2): ";
cin >> def >> znak >> mid >> znak >> fwd;
cout << endl;
cout << "Choose style(contain,defensive,counter,standard,control,attacking,overload): " << endl;
cin >> style;
cout << endl;
}