Question: You will create a game based on the Rock, Paper, Scissors game you may have played in your childhood. The player in the game will

You will create a game based on the Rock, Paper, Scissors game you may have played in your childhood. The player in the game will compete against the computer. You will first display a welcome screen. The user will press a key to continue and will then be prompted to "make a move" by specifying rock (R), paper (P), or scissors (S). The player may also quit the game by entering the letter Q. Once the player makes a move, the computer will make a move, determine the winner of that round, and display the result. The player will then be prompted to make another move. If the player enters anything other than R, P, S, or Q, a message will be displayed saying the selection is invalid. The game will end when the player enters a Q. At that point, another message will be displayed, followed by another screen displaying the game statistics.
Overview:
At this point, you should have already followed the Part 1 and Part 2 to have a working script that allows the user to play the game one time. For Part 3, you will edit and add on to the RockPaperScissors.ps1 script you have been working on.
Steps for Part 3:
1. Create an outer while loop to control the game play, allowing the users to play the game until they enter a "Q" to quit the game. This should come immediately after the Read-Host cmdlet following the game's opening screen. The entire game should be inside this loop, so the beginning { should be just before the random number assignment, and the closing } should be at the very end at this point. In this loop, you will compare the variable controlling the game play to "False" - i.e., the game will continue as long as this variable remains true.
2. You will need a second while loop just before you clear the screen and prompt the player to choose an option. Compare the variable holding the player's move to ""(blank space); this is what it should have been initialized to when it was declared. As long as it continues to be "", display the instructions. The closing } for the loop should be just before the validation of the player's move.
3. In the IF statement comparing the player's letter guess to "Q", add a "continue" as the last statement in the code block to skip the remainder of the loop. In the elseif comparing the player's letter guess R, P, or S, add a "continue" as the last statement in the code block to skip the remainder of the loop.
4. At the end of the game's main while loop, just before the closing }, the variable values should be reset to their default values to be ready for a new round of play. Reset the following: (1) variable storing numeric version of computer's move, (2) variable storing the letter version of the player's move, (3) variable storing the string (word) version of the computer's move, and (4) the variable storing the string (word) version of the player's move.
5. $computerMoveNum ="" #Variable to store the numeric version of the computer's move
6. $robotChoiceNum ="" #Computer's numeric choice
7. $robotChoiceWord ="" #Computer's Word choice
8.
9. $playerChoiceWord ="" #Player's Word choice
10. $playerChoiceLet ="" #Player's letter choice
11.
12. $tie ="" #Variable to keep track of tied games
13.
14. $gamePlay = $true #To control gameplay
15. $gamesPlayed ="" #Number of games played
16. $gamesLost ="" #Variable to keep track of the number of games lost
17. $gamesWon ="" #Variable to keep track of games won
18.
19. #Clears screen before beginning, writes welcome message on screen
20. cls
21. Write-host "Welcome to the `n `n `vRock, Paper, Scissors Game"
22. Write-host "`n `v `vPress Enter to continue"
23. $player = Read-Host
24. Start-Sleep -seconds 0.5; Read-Host
25.
26. while ($gamePlay = $true)
27.{
28.
29. cls
30. #Chooses a random number between 1 and 3; 1=Rock 2=Paper 3=Scissors
31. $robotChoiceNum = Get-Random -Minimum 1-Maximum 4
32.
33. #Sets number to matching word
34. if ($robotChoiceNum -eq 1)
35.{
36. $robotChoiceWord = "Rock"
37.}
38. if ($robotChoiceNum -eq 2)
39.{
40. $robotChoiceWord = "Paper"
41.}
42. if ($robotChoiceNum -eq 3)
43.{
44. $robotChoiceWord = "Scissors"
45.}
46.
47. while ($playerChoiceLet ="")
48.{
49. cls
50. Write-Host "Enter one of the following options: "
51. $dash ="-"*35
52. Write-Host $dash`n
53. Write-Host "R = Rock `nP = Paper `nS = Scissors `nQ = Quit`n"
54. Write-Host $dash`n
55. #Write-Host "Make a move "
56.
57. # Validate player's move
58. $playerChoiceLet = Read-Host "Make a move"
59.}
60. if ($playerChoiceLet -eq "Q")
61.{
62. Clear-Host
63. Write-Host "Thank you for playing!"
64. $gamePlay = $true
65. continue #Skip the remainder of the loop
66.}
67. elseif ($playerChoiceLet -notin "R","P","S")
68.{
69. Write-Host "Invalid input. Please try again."
70
Can you correct my code its not working.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!