From aa64b5526b23055f12b26603996a778728ec45ed Mon Sep 17 00:00:00 2001 From: fdai7472 Date: Mon, 5 Feb 2024 20:29:48 +0100 Subject: [PATCH] refactoring: konstanten Wert durch konstante Variable ersetzt --- src/main/c/Stefan/blackjack.c | 10 +++++----- src/main/c/Stefan/blackjack.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/c/Stefan/blackjack.c b/src/main/c/Stefan/blackjack.c index 112c91b..deadcdf 100644 --- a/src/main/c/Stefan/blackjack.c +++ b/src/main/c/Stefan/blackjack.c @@ -68,19 +68,19 @@ int userInputBJ(){ int getRandCard(int offset){ srand(time(NULL) + offset); - int r = rand() % 13; + int r = rand() % ANZ_MOEGLICHE_KARTEN; r++; - + // 11, 12, 13 = Bube, Dame, König haben den Wert 10 if(r > 10){ return 10; - } else if(r == 1){ + } + // Ass (1) hat erstmal den Wert 11 + else if(r == 1){ return 11; } return r; - - } diff --git a/src/main/c/Stefan/blackjack.h b/src/main/c/Stefan/blackjack.h index 3723164..f20062f 100644 --- a/src/main/c/Stefan/blackjack.h +++ b/src/main/c/Stefan/blackjack.h @@ -3,6 +3,8 @@ #include +#define ANZ_MOEGLICHE_KARTEN 13 + int blackjack(); void welcomeMessageBJ(); int getBalanceBJ();