Stone Paper Scissor or Rock Paper Scissor is a game played between two players where each player in this game forms one of three shapes and the winner is decided as per the rules of the game.
Description of the Project
It is a simple command line interface project for Rock, Paper, and Scissors games. The user gets the first chance to pick the Rock, Paper, or Scissors. After that computer makes a choice randomly and the winner is decided as per the game rules.
If both players use the same shape, it is considered a draw.
Prerequisites: C++ Basics, Functions, Random Number Generation, Conditional Statements
Components of the Program
The game is implemented with the help of the following components:
Header Files: A necessary standard template library has been added for performing operations such as Random number generation, input/output, etc.
getResults() Function: It compares the input of the computer and the player and gives the result of 1 for the win, 0 for the tie, and -1 for the loss.
getComputerMove() Function: This function uses a random number generator and returns the computer move based on the randomly generated number.
main() Function: In this, the main logic of the code is written, the player needs to choose 's' for (stone), 'p' for ( paper), or 'z' for (scissors). Then random input will be generated by the computer and the game function is called. this function will return an integer for the result and based on that result winner will be shown.