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