diff --git a/src/c/rockPaperScissors.c b/src/c/rockPaperScissors.c index 9b314e0..1da33e6 100644 --- a/src/c/rockPaperScissors.c +++ b/src/c/rockPaperScissors.c @@ -24,17 +24,22 @@ int playRockPaperScissors(int rounds){ void runGame(int *playerWins, int *computerWins){ int computerInput, playerInput; int roundwinner = NOWINNER; - + playerInput = getPlayerInput(); computerInput = getComputerInput(); roundwinner = findWinner(playerInput, computerInput); + setScore(roundwinner, playerWins, computerWins); + printResult(playerInput, computerInput, roundwinner, *playerWins, *computerWins); +} + + +void setScore(int roundwinner, int *playerWins, int *computerWins){ if (roundwinner == PLAYERWINSROUND){ *playerWins += 1; } else if (roundwinner == COMPUTERWINSROUND){ *computerWins += 1; } - printResult(playerInput, computerInput, roundwinner, *playerWins, *computerWins); } diff --git a/src/c/rockPaperScissors.h b/src/c/rockPaperScissors.h index fd6333f..224a20d 100644 --- a/src/c/rockPaperScissors.h +++ b/src/c/rockPaperScissors.h @@ -32,5 +32,6 @@ void printPrompt(int roundsToWin); void printResult(int playerInput, int computerInput, int roundWinner, int playerWins, int computerWins); void printWinner(int winner); void runGame(int *playerWins, int *computerWins); +void setScore(int roundwinner, int *playerWins, int *computerWins); #endif \ No newline at end of file