diff --git a/src/main/c/Stefan/blackjack.c b/src/main/c/Stefan/blackjack.c index 9c353d4..5a0a77d 100644 --- a/src/main/c/Stefan/blackjack.c +++ b/src/main/c/Stefan/blackjack.c @@ -1,5 +1,7 @@ #include "blackjack.h" #include +#include +#include int blackjack(){ @@ -10,6 +12,7 @@ int blackjack(){ int balance = getBalanceBJ(); int bet = getBetBJ(balance); printf("bet: %d\n", bet); + printf("rand card: %d\n", getRandCard()); return 0; } @@ -42,3 +45,22 @@ int userInputBJ(){ scanf("%d", &input); return input; } + +// Liefert eine Zufallszahl zwischen 1 und 10 +// Chance für 10 ist 4 Mal höher als für den Rest +// 1 = Ass +int getRandCard(){ + + srand(time(NULL)); + + int r = rand() % 13; + r++; + + if(r > 10){ + return 10; + } + + return r; + + +} \ No newline at end of file diff --git a/src/main/c/Stefan/blackjack.h b/src/main/c/Stefan/blackjack.h index 8f7fe1e..bfc4f73 100644 --- a/src/main/c/Stefan/blackjack.h +++ b/src/main/c/Stefan/blackjack.h @@ -6,5 +6,6 @@ int blackjack(); int getBalanceBJ(); int getBetBJ(int balance); int userInputBJ(); +int getRandCard(); #endif // BLACKJACK_H \ No newline at end of file