Browse Source

refactoring: neue konstante Variable MAX_CARDS definiert

remotes/origin/stefan
fdai7472 11 months ago
parent
commit
8f26a6f8a4
  1. 10
      src/main/c/Stefan/blackjack.c
  2. 1
      src/main/c/Stefan/blackjack.h

10
src/main/c/Stefan/blackjack.c

@ -89,13 +89,15 @@ int playBJ(int bet, int balance){
int winnings = 0;
int userCardsTotal = 0, dealerCardsTotal = 0;
int *dealerCardsArray = (int*) malloc(10 * sizeof(int));
// Array mit max 10 Karten anlegen
int *dealerCardsArray = (int*) malloc(MAX_CARDS * sizeof(int));
if(dealerCardsArray){
dealerCardsArray[0] = getRandCard(0);
printf("computer rand card: %d\n", dealerCardsArray[0]);
int *userCardsArray = (int*) malloc(10 * sizeof(int));
// Array mit max 10 Karten anlegen
int *userCardsArray = (int*) malloc(MAX_CARDS * sizeof(int));
if(userCardsArray){
@ -111,7 +113,7 @@ int playBJ(int bet, int balance){
for(int i = 2; i < 10; i++){
for(int i = 2; i < MAX_CARDS; i++){
userCardsTotal = calculateCardsTotal(userCardsArray, i);
@ -134,7 +136,7 @@ int playBJ(int bet, int balance){
}
for(int i = 1; i < 10; i++){
for(int i = 1; i < MAX_CARDS; i++){
dealerCardsTotal = calculateCardsTotal(dealerCardsArray, i);

1
src/main/c/Stefan/blackjack.h

@ -4,6 +4,7 @@
#include <stdbool.h>
#define ANZ_MOEGLICHE_KARTEN 13
#define MAX_CARDS 10
int blackjack();
void welcomeMessageBJ();

Loading…
Cancel
Save