diff --git a/src/main/c/Stefan/slot_machine.c b/src/main/c/Stefan/slot_machine.c index c3dbd65..d959827 100644 --- a/src/main/c/Stefan/slot_machine.c +++ b/src/main/c/Stefan/slot_machine.c @@ -3,6 +3,7 @@ #include #include #include +#include void slotMachine(){ @@ -117,6 +118,11 @@ int getWinnings(char symbols[], int bet){ } } } + + if(checkForMaxWin(symbols)){ + winnings *= 10; + } + if (winnings > 0) { printf("\nDu hast %d gewonnen!\n", winnings - bet); } @@ -127,6 +133,17 @@ int getWinnings(char symbols[], int bet){ return winnings; } +bool checkForMaxWin(char symbols[]){ + bool maxWin = true; + for(int i = 1; i < NUM_OF_SYMBOLS; i++){ + if(symbols[0] != symbols[i]){ + maxWin = false; + return maxWin; + } + } + return maxWin; +} + void showResult(char symbols[], int winnings){ char winnerMessage[10] = {""}; diff --git a/src/main/c/Stefan/slot_machine.h b/src/main/c/Stefan/slot_machine.h index c08b4bb..0e02b9f 100644 --- a/src/main/c/Stefan/slot_machine.h +++ b/src/main/c/Stefan/slot_machine.h @@ -1,6 +1,7 @@ #ifndef SLOT_MACHINE_H #define SLOT_MACHINE_H +#include #define NUM_OF_SYMBOLS 9 #define ROWS 3 @@ -15,5 +16,6 @@ void randomizeSymbols(char symbols[]); int spin(char symbols[], int bet, int balance); int getWinnings(char symbols[], int bet); void showResult(char symbols[], int winnings); +bool checkForMaxWin(char symbols[]); #endif // SLOT_MACHINE_H \ No newline at end of file diff --git a/src/test/c/Stefan/test_slot_machine.c b/src/test/c/Stefan/test_slot_machine.c index ff44d97..1fd8b1d 100644 --- a/src/test/c/Stefan/test_slot_machine.c +++ b/src/test/c/Stefan/test_slot_machine.c @@ -195,12 +195,12 @@ void test_3_C_3_D_won_bet_equals_10() { TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } -void test_9_A_won_bet_equals_10() { +void test_9_A_max_win_bet_equals_10() { //arrange char testSymbols[] = {"AAAAAAAAA"}; - int expectedResult = 90; + int expectedResult = 900; //act int actualResult = getWinnings(testSymbols, 10);