In the program I am making I'm trying to make sure that the user does not select each option more than once. The code goes in order of the first number compares with the others then second number with comparisons to the others and finally the third number. When I run the program it only runs correctly for the first number. The others just accept the value regardless if it fits within the parameters or not.
Code:
bool SkillCompare(int& skillone, int& skilltwo)
{
if (skillone != skilltwo && skillone <= 10 && skillone >= 0)
{
return true;
}
else
{
return false;
}
}
if ((SkillCompare(intskill1, intskill2)) == true && ((SkillCompare(intskill1, intskill3))) == true)
{
intskill1 = intskill1;
}
else
{
do
{
cout << "You have selected an invalid skill, please select your first skill again using the correct number:" << endl;
cin >> intskill1;
cout << endl;
} while ((SkillCompare(intskill1,intskill2) == false) && (SkillCompare(intskill1, intskill3) == false));
}
if ((SkillCompare(intskill2, intskill1)) == true && ((SkillCompare(intskill2, intskill3))) == true)
{
intskill2 = intskill2;
}
else
{
do
{
cout << "You have selected an invalid skill, please select your second skill again using the correct number:" << endl;
cin >> intskill2;
cout << endl;
} while ((SkillCompare(intskill2,intskill1) == false) && (SkillCompare(intskill2, intskill3) == false));
}
if ((SkillCompare(intskill3, intskill1)) == true && ((SkillCompare(intskill3, intskill2))) == true)
{
intskill3 = intskill3;
}
else
{
do
{
cout << "You have selected an invalid skill, please select your third skill again using the correct number:" << endl;
cin >> intskill3;
cout << endl;
} while ((SkillCompare(intskill3,intskill1) == false) && (SkillCompare(intskill3, intskill2) == false));
}