From c9604b763599a2d95fc6d94b804951f062fd6ff4 Mon Sep 17 00:00:00 2001 From: fdai7472 Date: Mon, 5 Feb 2024 15:48:11 +0100 Subject: [PATCH] Implementierung getBet und userInput BJ --- src/main/c/Stefan/blackjack.c | 25 ++++++++++++++++++++++++- src/main/c/Stefan/blackjack.h | 2 ++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/main/c/Stefan/blackjack.c b/src/main/c/Stefan/blackjack.c index a7af619..9c353d4 100644 --- a/src/main/c/Stefan/blackjack.c +++ b/src/main/c/Stefan/blackjack.c @@ -8,6 +8,8 @@ int blackjack(){ printf("Welcome to Blackjack \n"); int balance = getBalanceBJ(); + int bet = getBetBJ(balance); + printf("bet: %d\n", bet); return 0; } @@ -16,6 +18,27 @@ int getBalanceBJ(){ int balance = 0; printf("Guthaben einwerfen: "); scanf("%d", &balance); - printf("Dein Guthaben: %d", balance); + printf("Dein Guthaben: %d\n", balance); return balance; } + +int getBetBJ(int balance){ + + while(1){ + printf("Wetteinsatz: "); + int bet = userInputBJ(); + + if(bet <= balance && bet > 0){ + return bet; + } else { + printf("Ungueltige Eingabe!\n"); + } + + } +} + +int userInputBJ(){ + int input; + scanf("%d", &input); + return input; +} diff --git a/src/main/c/Stefan/blackjack.h b/src/main/c/Stefan/blackjack.h index 69f1176..8f7fe1e 100644 --- a/src/main/c/Stefan/blackjack.h +++ b/src/main/c/Stefan/blackjack.h @@ -4,5 +4,7 @@ int blackjack(); int getBalanceBJ(); +int getBetBJ(int balance); +int userInputBJ(); #endif // BLACKJACK_H \ No newline at end of file