Browse Source

Wetteinsatz vom Guthaben abziehen + erster Test dazu

remotes/origin/dev
fdai7472 11 months ago
parent
commit
d15d3aa55b
  1. 7
      src/main/c/Stefan/slot_machine.c
  2. 1
      src/main/c/Stefan/slot_machine.h
  3. 12
      src/test/c/Stefan/test_slot_machine.c

7
src/main/c/Stefan/slot_machine.c

@ -10,8 +10,7 @@ void slotMachine(){
while(balance > 0){ while(balance > 0){
int bet = getBet(balance); int bet = getBet(balance);
balance -= bet;
printf("%d\n", balance);
balance = subtractBetFromBalance(bet, balance);
} }
@ -47,6 +46,10 @@ int getBet(int balance){
} }
} }
int subtractBetFromBalance(int bet, int balance){
return balance - bet;
}
void welcomeMessage(){ void welcomeMessage(){
printf("Herzlich Willkommen zur \n\n" printf("Herzlich Willkommen zur \n\n"
" _ _ _ _ \n" " _ _ _ _ \n"

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

@ -6,5 +6,6 @@ void welcomeMessage();
int getBalance(); int getBalance();
int userInput(); int userInput();
int getBet(int balance); int getBet(int balance);
int subtractBetFromBalance(int bet, int balance);
#endif // SLOT_MACHINE_H #endif // SLOT_MACHINE_H

12
src/test/c/Stefan/test_slot_machine.c

@ -5,4 +5,14 @@ void setUp() {}
void tearDown() {} void tearDown() {}
void test_test(){}
void test_subtract_bet_10_from_balance_10() {
//arrange
int expectedResult = 0;
//act
int actualResult = subtractBetFromBalance(10, 10);
//assert
TEST_ASSERT_EQUAL_INT(expectedResult, actualResult);
}
Loading…
Cancel
Save