Browse Source

Ergebnis anzeigen implementiert + typo in .h korrigiert ROWS 9 -> ROWS 3

remotes/origin/dev
fdai7472 11 months ago
parent
commit
a34f5abef4
  1. 8
      src/main/c/Stefan/slot_machine.c
  2. 3
      src/main/c/Stefan/slot_machine.h

8
src/main/c/Stefan/slot_machine.c

@ -89,6 +89,7 @@ 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); int winnings = getWinnings(symbols, bet);
showResult(symbols);
return balance; return balance;
} }
@ -119,6 +120,13 @@ int getWinnings(char symbols[], int bet){
return winnings; return winnings;
} }
void showResult(char symbols[]){
for (int i = 0; i < ROWS; i++){
printf(" %c | %c | %c\n", symbols[i * ROWS], symbols[i * ROWS + 1], symbols[i * ROWS + 2]);
}
}
void welcomeMessage(){ void welcomeMessage(){
printf("Herzlich Willkommen zur \n\n" printf("Herzlich Willkommen zur \n\n"
" _ _ _ _ \n" " _ _ _ _ \n"

3
src/main/c/Stefan/slot_machine.h

@ -3,7 +3,7 @@
#define NUM_OF_SYMBOLS 9 #define NUM_OF_SYMBOLS 9
#define ROWS 9
#define ROWS 3
void slotMachine(); void slotMachine();
void welcomeMessage(); void welcomeMessage();
@ -14,5 +14,6 @@ int subtractBetFromBalance(int bet, int balance);
void randomizeSymbols(char symbols[]); void randomizeSymbols(char symbols[]);
int spin(char symbols[], int bet, int balance); int spin(char symbols[], int bet, int balance);
int getWinnings(char symbols[], int bet); int getWinnings(char symbols[], int bet);
void showResult(char symbols[]);
#endif // SLOT_MACHINE_H #endif // SLOT_MACHINE_H
Loading…
Cancel
Save