I have a 2D array which some of it’s members are numbers (playerID -1,2,3,4 etc.)and the rest are zeros.
I want to make a for loop containing all kinds of check methods that goes through the the loop and returns an answer. the checks are ranked, so that when one of the higher checks is returned TRUE, the loop for that playerID can terminate. Later on I want to use the check results to compare between the players, but first thing’s first – I can’t get the big FOR loop running.
I had in mind something like this:
for (int playerID = 1; playerID <= participants; playerID++)
{
checkA = Check4forsequenceof4(matrix); //method A
if (checkA == 0)
continue;
else
Console.WriteLine(p + "completed check A");
break;
if (checkB == 0)
continue;
else
Console.WriteLine(p + "completed check B");
break;
if (checkC == 0)
continue;
else
Console.WriteLine(p + "completed check C");
break;
}
Problems are: the break breaks out of the FOR loop instead of only from the if, and I can’t think of how to check for the next playerID, and also can’t figure out how best to store the results for every player for later display.
First off, if you want to make this work, you can’t rely on indentation – you need braces:
This will solve your immediate problem of the loop immediately breaking out.
That being said, given the above check, you’ll NEVER check for B. I suspect you want to invert your logic, as such:
This will cause checkA to run, then checkB, etc.