This program is a simple rock, paper, scissors game where the player has to choose one of the three options to beat the computer. The computer will generate a random option by creating a number to indicate that option. 1 will be 'rock', 2 will be 'paper', and 3 will be 'scissors'. The expect outcome should look like this:
Before we begin, let's set the values of rock, paper, and scissors to a number like so:
Now, let's make an options board. This will allow the user to pick between rock, paper, or scissors. Print out the options for the player to pick like this:
Next, we have to let the user pick and display their choice. We're displaying their number by comparing user value to our set constant values.
Once we have the user's choice, we need the get the computer's choice to see who is going to win. To do this we're going to randomly generate a number between 1-3 and display the computer's choice.
With both choices, we're ready to compare them and see who is the winner! Make a function that will determine all outcomes. Rock will beat scissors, scissors will beat paper, and paper will beat rocks. We should display the outcome if the computer or user wins. Don't forget to display a tie if both choices match.
And that's it! Those were the basic steps into making a rock, paper, scissors game in C++. All the code that was used for the program looks like this:
Top comments (2)
Why you didn't share the code?
This answer looks good to me
kodlogs.com/38773/rock-paper-sciss...