From f87ef43a2c84b147cc0b586f74381f95020f92c6 Mon Sep 17 00:00:00 2001 From: fdai7472 Date: Mon, 29 Jan 2024 16:03:07 +0100 Subject: [PATCH] Eingabe Wetteinsatz added --- src/main/c/Stefan/slot_machine.c | 15 ++++++++++++++- src/main/c/Stefan/slot_machine.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/c/Stefan/slot_machine.c b/src/main/c/Stefan/slot_machine.c index ff07038..dfddd13 100644 --- a/src/main/c/Stefan/slot_machine.c +++ b/src/main/c/Stefan/slot_machine.c @@ -7,7 +7,12 @@ void slotMachine(){ int balance = getBalance(); + while(balance > 0){ + int bet = getBet(balance); + balance -= bet; + printf("%d\n", balance); + } @@ -18,7 +23,7 @@ int getBalance(){ int balance; printf("Guthaben einwerfen: "); balance = userInput(); - printf("Dein Guthaben: %d", balance); + printf("Dein Guthaben: %d\n", balance); return balance; } @@ -28,6 +33,14 @@ int userInput(){ return input; } +int getBet(int balance){ + int bet; + printf("Wetteinsatz: "); + bet = userInput(); + + return bet; +} + 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 56cebac..14a3217 100644 --- a/src/main/c/Stefan/slot_machine.h +++ b/src/main/c/Stefan/slot_machine.h @@ -5,5 +5,6 @@ void slotMachine(); void welcomeMessage(); int getBalance(); int userInput(); +int getBet(int balance); #endif // SLOT_MACHINE_H \ No newline at end of file