From 6faa5dfbffd4786f0ef9249562182728ed796ae8 Mon Sep 17 00:00:00 2001 From: Aimee Reincke Date: Tue, 24 Jan 2023 13:07:11 +0100 Subject: [PATCH] refactoring: added print winner + text --- src/c/rockPaperScissors.c | 13 +++++++++++-- src/c/rockPaperScissors.h | 2 -- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/c/rockPaperScissors.c b/src/c/rockPaperScissors.c index 5309aa4..14fb1cf 100644 --- a/src/c/rockPaperScissors.c +++ b/src/c/rockPaperScissors.c @@ -24,9 +24,9 @@ int playRockPaperScissors(int rounds){ computerWins += 1; } 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); +} + +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"); + } } \ No newline at end of file diff --git a/src/c/rockPaperScissors.h b/src/c/rockPaperScissors.h index ba5b38f..3c655e2 100644 --- a/src/c/rockPaperScissors.h +++ b/src/c/rockPaperScissors.h @@ -28,7 +28,5 @@ int wasGameWon(int roundsToWin, int playerWins, int computerWins); bool validatePlayerInput(int playerInput); int getPlayerInput(); int playRockPaperScissors(int rounds); -void printPrompt(int roundsToWin); -void printResult(int playerInput, int computerInput, int roundWinner, int playerWins, int computerWins); #endif \ No newline at end of file