Browse Source

print round results

remotes/origin/SchereSteinPapier
Aimee Reincke 2 years ago
parent
commit
ece1a547ef
  1. 25
      src/c/rockPaperScissors.c
  2. 1
      src/c/rockPaperScissors.h

25
src/c/rockPaperScissors.c

@ -97,4 +97,29 @@ int wasGameWon(int roundsToWin, int playerWins, int computerWins){
void printPrompt(int roundsToWin){ void printPrompt(int roundsToWin){
printf("Hello NAME.\nLet us play a game, shall we? I assume you are familiar with Rock-Paper-Scissors?\nIf not, here are the rules:\nThe first one to win %d rounds wins the game. Rock beats scissors, scissors beats paper and paper beats rock.\nThey are quite simple, even you should understand. Got it?\n", roundsToWin); printf("Hello NAME.\nLet us play a game, shall we? I assume you are familiar with Rock-Paper-Scissors?\nIf not, here are the rules:\nThe first one to win %d rounds wins the game. Rock beats scissors, scissors beats paper and paper beats rock.\nThey are quite simple, even you should understand. Got it?\n", roundsToWin);
}
void printResult(int playerInput, int computerInput, int roundWinner, int playerWins, int computerWins){
switch (playerInput){
case ROCK: printf("So you chose rock.\n"); break;
case PAPER: printf("So you chose paper.\n"); break;
case SCISSORS: printf("So you chose scissors.\n"); break;
}
switch (roundWinner)
{
case PLAYERWINSROUND: printf("Seems you win this round, I chose "); break;
case COMPUTERWINSROUND: printf("Too bad for you. I win this one, I chose "); break;
case NOWINNER: printf("Looks like it's a draw, I also chose "); break;
}
switch (computerInput)
{
case ROCK: printf("rock.\n"); break;
case PAPER: printf("paper.\n"); break;
case SCISSORS: printf("scissors.\n"); break;
}
printf("With this, you are at %d wins and I am at %d.\n", playerWins, computerWins);
} }

1
src/c/rockPaperScissors.h

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