Browse Source

Gewinne werden jetzt angezeigt

remotes/origin/dev
fdai7472 11 months ago
parent
commit
607f656bed
  1. 11
      src/main/c/Stefan/slot_machine.c

11
src/main/c/Stefan/slot_machine.c

@ -88,8 +88,8 @@ void randomizeSymbols(char symbols[]){
int spin(char symbols[], int bet, int balance){ int spin(char symbols[], int bet, int balance){
int winnings = getWinnings(symbols, bet);
showResult(symbols); showResult(symbols);
int winnings = getWinnings(symbols, bet);
return balance; return balance;
} }
@ -113,15 +113,20 @@ int getWinnings(char symbols[], int bet){
case 'C': winnings = bet * 10; break; case 'C': winnings = bet * 10; break;
case 'D': winnings = bet * 20; break; case 'D': winnings = bet * 20; break;
} }
} }
} }
if (winnings > 0) {
printf("\nDu hast %d gewonnen!\n", winnings - bet);
}
else {
printf("\nLeider verloren.\n");
}
return winnings; return winnings;
} }
void showResult(char symbols[]){ void showResult(char symbols[]){
for (int i = 0; i < ROWS; i++){ for (int i = 0; i < ROWS; i++){
printf(" %c | %c | %c\n", symbols[i * ROWS], symbols[i * ROWS + 1], symbols[i * ROWS + 2]); printf(" %c | %c | %c\n", symbols[i * ROWS], symbols[i * ROWS + 1], symbols[i * ROWS + 2]);
} }

Loading…
Cancel
Save