|
@ -8,14 +8,20 @@ int blackjack(){ |
|
|
|
|
|
|
|
|
printf("Welcome to Blackjack \n\n"); |
|
|
printf("Welcome to Blackjack \n\n"); |
|
|
|
|
|
|
|
|
|
|
|
bool exit = false; |
|
|
|
|
|
bool *exitPtr = &exit; |
|
|
int balance = getBalanceBJ(); |
|
|
int balance = getBalanceBJ(); |
|
|
|
|
|
|
|
|
while(balance > 0){ |
|
|
while(balance > 0){ |
|
|
printf("Aktuelles Guthaben: %d\n", balance); |
|
|
printf("Aktuelles Guthaben: %d\n", balance); |
|
|
int bet = getBetBJ(balance); |
|
|
|
|
|
|
|
|
int bet = getBetBJ(balance, exitPtr); |
|
|
|
|
|
if(exit) { |
|
|
|
|
|
return -1; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
balance -= bet; |
|
|
balance -= bet; |
|
|
|
|
|
|
|
|
playBJ(bet, balance); |
|
|
|
|
|
|
|
|
balance = playBJ(bet, balance); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return 0; |
|
|
return 0; |
|
@ -24,18 +30,21 @@ int blackjack(){ |
|
|
int getBalanceBJ(){ |
|
|
int getBalanceBJ(){ |
|
|
printf("Guthaben einwerfen: "); |
|
|
printf("Guthaben einwerfen: "); |
|
|
int balance = userInputBJ(); |
|
|
int balance = userInputBJ(); |
|
|
printf("Dein Guthaben: %d\n", balance); |
|
|
|
|
|
return balance; |
|
|
return balance; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
int getBetBJ(int balance){ |
|
|
|
|
|
|
|
|
int getBetBJ(int balance, bool *exitPtr){ |
|
|
|
|
|
|
|
|
while(1){ |
|
|
while(1){ |
|
|
|
|
|
printf("\nGib (0) ein, um Blackjack zu verlassen.\n"); |
|
|
printf("Wetteinsatz: "); |
|
|
printf("Wetteinsatz: "); |
|
|
int bet = userInputBJ(); |
|
|
int bet = userInputBJ(); |
|
|
|
|
|
|
|
|
if(bet <= balance && bet > 0){ |
|
|
if(bet <= balance && bet > 0){ |
|
|
return bet; |
|
|
return bet; |
|
|
|
|
|
} else if(bet == 0) { |
|
|
|
|
|
*exitPtr = true; |
|
|
|
|
|
break; |
|
|
} else { |
|
|
} else { |
|
|
printf("Ungueltige Eingabe!\n"); |
|
|
printf("Ungueltige Eingabe!\n"); |
|
|
} |
|
|
} |
|
|