diff --git a/src/main/c/Stefan/slot_machine.c b/src/main/c/Stefan/slot_machine.c index 5acc8bf..e6395ba 100644 --- a/src/main/c/Stefan/slot_machine.c +++ b/src/main/c/Stefan/slot_machine.c @@ -108,10 +108,10 @@ int getWinnings(char symbols[], int bet){ if (symbols[i * ROWS] == symbols[i * ROWS + 1] && symbols[i * ROWS] == symbols[i * ROWS + 2]) { switch(symbols[i * ROWS]){ - case 'A': winnings = bet * 3; break; - case 'B': winnings = bet * 5; break; - case 'C': winnings = bet * 10; break; - case 'D': winnings = bet * 20; break; + case 'A': winnings += bet * 3; break; + case 'B': winnings += bet * 5; break; + case 'C': winnings += bet * 10; break; + case 'D': winnings += bet * 20; break; } } } diff --git a/src/test/c/Stefan/test_slot_machine.c b/src/test/c/Stefan/test_slot_machine.c index 8a05f53..3739660 100644 --- a/src/test/c/Stefan/test_slot_machine.c +++ b/src/test/c/Stefan/test_slot_machine.c @@ -16,6 +16,7 @@ void test_subtract_bet_10_from_balance_10() { //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } + void test_subtract_bet_0_from_balance_10() { //arrange @@ -109,3 +110,87 @@ void test_3_D_won_bet_equals_10() { //assert TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); } + +void test_6_A_won_bet_equals_10() { + + //arrange + char testSymbols[] = {"AAAAAACAC"}; + + int expectedResult = 60; + + //act + int actualResult = getWinnings(testSymbols, 10); + + //assert + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_6_B_won_bet_equals_10() { + + //arrange + char testSymbols[] = {"BBBBBBCAC"}; + + int expectedResult = 100; + + //act + int actualResult = getWinnings(testSymbols, 10); + + //assert + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_6_C_won_bet_equals_10() { + + //arrange + char testSymbols[] = {"CCCCCCCAC"}; + + int expectedResult = 200; + + //act + int actualResult = getWinnings(testSymbols, 10); + + //assert + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_6_D_won_bet_equals_10() { + + //arrange + char testSymbols[] = {"DDDDDDCAC"}; + + int expectedResult = 400; + + //act + int actualResult = getWinnings(testSymbols, 10); + + //assert + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_3_A_3_B_won_bet_equals_10() { + + //arrange + char testSymbols[] = {"AAABBBCAC"}; + + int expectedResult = 80; + + //act + int actualResult = getWinnings(testSymbols, 10); + + //assert + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +} + +void test_3_C_3_D_won_bet_equals_10() { + + //arrange + char testSymbols[] = {"BAACCCDDD"}; + + int expectedResult = 300; + + //act + int actualResult = getWinnings(testSymbols, 10); + + //assert + TEST_ASSERT_EQUAL_INT(expectedResult, actualResult); +}