From a34f5abef406274b84df7004b5e89f602bef4715 Mon Sep 17 00:00:00 2001 From: fdai7472 Date: Mon, 29 Jan 2024 17:49:58 +0100 Subject: [PATCH] Ergebnis anzeigen implementiert + typo in .h korrigiert ROWS 9 -> ROWS 3 --- src/main/c/Stefan/slot_machine.c | 8 ++++++++ src/main/c/Stefan/slot_machine.h | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/c/Stefan/slot_machine.c b/src/main/c/Stefan/slot_machine.c index 2a9b689..54ac3e9 100644 --- a/src/main/c/Stefan/slot_machine.c +++ b/src/main/c/Stefan/slot_machine.c @@ -89,6 +89,7 @@ void randomizeSymbols(char symbols[]){ int spin(char symbols[], int bet, int balance){ int winnings = getWinnings(symbols, bet); + showResult(symbols); return balance; } @@ -119,6 +120,13 @@ int getWinnings(char symbols[], int bet){ 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(){ printf("Herzlich Willkommen zur \n\n" " _ _ _ _ \n" diff --git a/src/main/c/Stefan/slot_machine.h b/src/main/c/Stefan/slot_machine.h index dc37dae..3639e7e 100644 --- a/src/main/c/Stefan/slot_machine.h +++ b/src/main/c/Stefan/slot_machine.h @@ -3,7 +3,7 @@ #define NUM_OF_SYMBOLS 9 -#define ROWS 9 +#define ROWS 3 void slotMachine(); void welcomeMessage(); @@ -14,5 +14,6 @@ int subtractBetFromBalance(int bet, int balance); void randomizeSymbols(char symbols[]); int spin(char symbols[], int bet, int balance); int getWinnings(char symbols[], int bet); +void showResult(char symbols[]); #endif // SLOT_MACHINE_H \ No newline at end of file