C++ RPS

Jan 28, 2018 at 12:46am
this is for a rock paper scissors game
Function format we must use >>
bool isRoundWinner(char move, char opponent_move);
What should the function above look like for this part
char move and opponent move can be "R" or "r" of "s" "S" or "P" or "p"
Jan 28, 2018 at 12:59am
Here's an example for just Rock and Paper. Try to expand the logic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <cstdlib>
bool isRoundWinner(char move, char opponent_move)
{
    if (tolower(move) == 'r' && tolower(opponent_move) == 'p')
        return false; // lose

    if (tolower(move) == 'p' && tolower(opponent_move) == 'r')
        return true; // win;

    // determine the other possible combinations that cause you to win or lose
    // ...

    return false; // placeholder
}
Jan 28, 2018 at 5:58am
Topic archived. No new replies allowed.