Developing a program to play the game rock-paper-scissors


Write a program which permits the user to play the game Rock, Paper, Scissors against the computer. The program must work as follows:

• When the program begins, the results of the previous run of the program (ie - how many wins the user had versus how many wins the computer had) are read from a file and displayed. Note - if this is the very first execution of the program then a welcome message is shown.

• A method is called to find the computer's selection. In the method, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has selected rock. If the number is 2, then the computer has selected paper. If the number is 3, then the computer has selected scissors. (Do not display computer's selection yet).

• The user enters his or her selection of "rock", "paper", or "scissors" at the keyboard. (You could use a menu for user input if you prefer). Remember to authenticate user input.

• The computer's selection is displayed.

• A method is called to find the winner according to the following rules:

i) If one player selects rock and the other player selects scissors, then rock wins. Rock smashes scissors.

ii) If one player selects scissors and the other player selects paper, then scissors wins. Scissors cut paper.

iii) If one player selects paper and the other selects rock, then paper wins. Paper covers rock.

iv) If both players make the same selection, the game should be played again to find the winner.

• A count of the number of wins for the user and for the computer is kept.

• The user is given the opportunity to play again.

• When the user is finished playing, the count values are written to the screen and to an output file for later use.

Remember to use good programming practices!

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Developing a program to play the game rock-paper-scissors
Reference No:- TGS01803

Expected delivery within 24 Hours