C++ RPS

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"
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
}
Topic archived. No new replies allowed.