diff --git a/src/c/rockPaperScissors.c b/src/c/rockPaperScissors.c index 40a00fe..0171e87 100644 --- a/src/c/rockPaperScissors.c +++ b/src/c/rockPaperScissors.c @@ -6,31 +6,20 @@ char findWinner(int inputPlayer, int inputComputer){ + if (inputPlayer == inputComputer){ - return 'n'; + return NOWINNER; + } + else if (inputPlayer == ROCK && inputComputer == SCISSORS) { + return PLAYERWINSROUND; } - else if (inputPlayer == ROCK){ - if (inputComputer == SCISSORS){ - return 'p'; - } - else if (inputComputer == PAPER){ - return 'c'; - } + else if (inputPlayer == PAPER && inputComputer == ROCK) { + return PLAYERWINSROUND; } - else if (inputPlayer == PAPER){ - if (inputComputer == ROCK){ - return 'p'; - } - else if (inputComputer == SCISSORS){ - return 'c'; - } + else if (inputPlayer == SCISSORS && inputComputer == PAPER) { + return PLAYERWINSROUND; } - else if (inputPlayer == SCISSORS){ - if (inputComputer == PAPER){ - return 'p'; - } - else if (inputComputer == ROCK){ - return 'c'; - } + else { + return COMPUTERWINSROUND; } } \ No newline at end of file diff --git a/src/c/rockPaperScissors.h b/src/c/rockPaperScissors.h index 7ce0730..cda1894 100644 --- a/src/c/rockPaperScissors.h +++ b/src/c/rockPaperScissors.h @@ -2,11 +2,18 @@ #define ROCKPAPERSCISSORS_H enum inputOptions{ - ROCK = 1, - PAPER = 2, - SCISSORS = 3 - }; + ROCK, + PAPER, + SCISSORS +}; +enum roundWinner{ + PLAYERWINSROUND = 'p', + COMPUTERWINSROUND = 'c', + NOWINNER = 'n' +}; + + char findWinner(int inputPlayer, int inputComputer); #endif \ No newline at end of file