Okay, here'shere is how I would reduce the code duplication (if I'mI am understanding the conditions correctly):
Edit: Original:
bool runCompleted(bool checked, string done)
{
if( ( checked && done == "done" ) || !checked )
return true;
else
return false;
}
New version based on Jerry's feedback:
bool runCompleted(bool checked, string done)
{
return !checked || done == "done";
}
Then in your code:
if( runCompleted(runPart1.Checked, cmdPart1 )
&& runCompleted(runpart2.Checked, cmdPart2 )
&& runCompleted(runpart3.Checked, cmdPart2cmdPart3 )
&& runCompleted(runpart4.Checked, cmdPart2cmdPart4 )
)
allDone();