-
if (spin == SpinnerT::ONE_CHERRY) {
bunch of actions with the number 1
} else if (spin == SpinnerT::TWO_CHERRY)
same actions, but with the number 2
} else if (spin == SpinnerT::TWO_CHERRY)
same actions, but with the number 3
...
- First of all use a case.
- Secondly, write a single function that takes a parameter
-
// I am not overjoyed with this code. see below.
switch (spin) {
case SpinnerT::ONE_CHERRY:
AddCherries(player, 1);
break;
case SpinnerT::TWO_CHERRY:
AddCherries(player, 2);
break;
case SpinnerT::THREE_CHERRY:
AddCherries(player, 3);
break;
....
case SpinnerT::BIRD:
case SpinnerT::DOG:
DeleteCherries(player, 2, SpinnerTToString(spinner);
break;
}
...
- Or better yet
-
if (spin <= SpinnerT::FOUR_CHERRY) {
AddCherries(player, spin);
} else {
DeleteCherries(player, spin);
}