From d5a649ab4022822627cf30db10f1649bbce0ae8a Mon Sep 17 00:00:00 2001 From: fdai7472 Date: Mon, 5 Feb 2024 16:23:05 +0100 Subject: [PATCH] Spiel wiederholt sich, solange man noch Guthaben hat + random Computer Card wird generiert --- src/main/c/Stefan/blackjack.c | 24 ++++++++++++++++++++++-- src/main/c/Stefan/blackjack.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/c/Stefan/blackjack.c b/src/main/c/Stefan/blackjack.c index 5a0a77d..9d99762 100644 --- a/src/main/c/Stefan/blackjack.c +++ b/src/main/c/Stefan/blackjack.c @@ -10,10 +10,16 @@ int blackjack(){ printf("Welcome to Blackjack \n"); int balance = getBalanceBJ(); - int bet = getBetBJ(balance); - printf("bet: %d\n", bet); + printf("rand card: %d\n", getRandCard()); + while(balance > 0){ + int bet = getBetBJ(balance); + balance -= bet; + + playBJ(bet, balance); + } + return 0; } @@ -63,4 +69,18 @@ int getRandCard(){ return r; +} + +int playBJ(int bet, int balance){ + + int *computerCardArray = (int*) malloc(10 * sizeof(int)); + + if(computerCardArray){ + computerCardArray[0] = getRandCard(); + printf("computer rand card: %d\n", computerCardArray[0]); + + free(computerCardArray); + } + + return balance; } \ No newline at end of file diff --git a/src/main/c/Stefan/blackjack.h b/src/main/c/Stefan/blackjack.h index bfc4f73..af00859 100644 --- a/src/main/c/Stefan/blackjack.h +++ b/src/main/c/Stefan/blackjack.h @@ -7,5 +7,6 @@ int getBalanceBJ(); int getBetBJ(int balance); int userInputBJ(); int getRandCard(); +int playBJ(int bet, int balance); #endif // BLACKJACK_H \ No newline at end of file