Browse Source

Implementierung Funktion, die Wetteinsatz vom Guthaben abzieht + Test

remotes/origin/stefan
fdai7472 12 months ago
parent
commit
77d4338a75
  1. 6
      src/main/c/Stefan/blackjack.c
  2. 1
      src/main/c/Stefan/blackjack.h
  3. 17
      src/test/c/Stefan/test_blackjack.c

6
src/main/c/Stefan/blackjack.c

@ -22,7 +22,7 @@ int blackjack(){
}
// Bei jeder Runde wird der Wetteinsatz vom Guthaben abgezogen
balance -= bet;
balance = subtractBetFromBalanceBJ(bet, balance);
// Nach jeder Runde wird das Guthaben aktualisiert
balance = playBJ(bet, balance);
@ -31,6 +31,10 @@ int blackjack(){
return 0;
}
int subtractBetFromBalanceBJ(int bet, int balance){
return balance - bet;
}
int getBalanceBJ(){
printf("Guthaben einwerfen: ");
int balance = userInputBJ();

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

@ -19,5 +19,6 @@ int calculateWinnings(bool blackjack, int bet);
bool hit();
bool calculateIfYouWon(int userCardsTotal, int computerCardsTotal);
char generateCardAscii(int cardValue);
int subtractBetFromBalanceBJ(int bet, int balance);
#endif // BLACKJACK_H

17
src/test/c/Stefan/test_blackjack.c

@ -282,4 +282,19 @@ void test_generate_char_for_card_5() {
//assert
TEST_ASSERT_EQUAL_CHAR(expected_result, actual_result);
}
}
void test_subtract_bet_10_from_balance_100() {
//arrange
int bet = 10;
int balance = 100;
int expected_result = 90;
//act
int actual_result = subtractBetFromBalanceBJ(bet, balance);
//assert
TEST_ASSERT_EQUAL_INT(expected_result, actual_result);
}
Loading…
Cancel
Save