Browse Source

refactoring: added print winner + text

remotes/origin/SchereSteinPapier
Aimee Reincke 2 years ago
parent
commit
6faa5dfbff
  1. 13
      src/c/rockPaperScissors.c
  2. 2
      src/c/rockPaperScissors.h

13
src/c/rockPaperScissors.c

@ -24,9 +24,9 @@ int playRockPaperScissors(int rounds){
computerWins += 1; computerWins += 1;
} }
winner = wasGameWon(roundsToWin, playerWins, computerWins); winner = wasGameWon(roundsToWin, playerWins, computerWins);
printf("Something happened\n");
printResult(playerInput, computerInput, roundwinner, playerWins, computerWins);
} }
printf("Someone won\n");
printWinner(winner);
} }
@ -122,4 +122,13 @@ void printResult(int playerInput, int computerInput, int roundWinner, int player
} }
printf("With this, you are at %d wins and I am at %d.\n", playerWins, computerWins); printf("With this, you are at %d wins and I am at %d.\n", playerWins, computerWins);
}
void printWinner(int winner){
if (winner == PLAYERWINSGAME){
printf("Damn you, you beat me! You actually won! Oh well, I stand by my word. You may pass.\n");
}
else if (winner == COMPUTERWINSGAME){
printf("Oh poor you, seems like I won. You're gomma have to try again. Do better next time.\n");
}
} }

2
src/c/rockPaperScissors.h

@ -28,7 +28,5 @@ int wasGameWon(int roundsToWin, int playerWins, int computerWins);
bool validatePlayerInput(int playerInput); bool validatePlayerInput(int playerInput);
int getPlayerInput(); int getPlayerInput();
int playRockPaperScissors(int rounds); int playRockPaperScissors(int rounds);
void printPrompt(int roundsToWin);
void printResult(int playerInput, int computerInput, int roundWinner, int playerWins, int computerWins);
#endif #endif
Loading…
Cancel
Save