Browse Source

Spiel wiederholt sich, solange man noch Guthaben hat + random Computer Card wird generiert

remotes/origin/stefan
fdai7472 11 months ago
parent
commit
d5a649ab40
  1. 24
      src/main/c/Stefan/blackjack.c
  2. 1
      src/main/c/Stefan/blackjack.h

24
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;
}

1
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
Loading…
Cancel
Save