samedi 28 mai 2016

How could you write the "if - then" logic for the game Yacht?

http://ift.tt/1X427Ct

I created 5 dice in my c++ program and they each roll random numbers from 1-6. So if you get all 1's its really simple. It's just:

if (dice1 == 1 && dice2 == 1 && dice3 == 1 && dice4 ==  1 && dice5 == 1)
{
int total = 50;
}

Also, summing all the dice is easy too. But how could you write the if-statement for "if two to four dice are the same then sum up those dice"? Is there a simple way you could do that?

Aucun commentaire:

Enregistrer un commentaire