Question: Can you complete code for Powershell Programming so CMDLETS My code isnt working properly 1 . Update the switch statement. Each code block in the
Can you complete code for Powershell Programming so CMDLETS My code isnt working properly Update the switch statement. Each code block in the if statements should include a line to increment one of the following variables: the variable holding the number of wins, the variable holding the number of losses, or the variable holding the number of ties. You will add each statement just before the WriteHost cmdlet. You will increment each by one. For example, $noTied
$computerMoveNum #Variable to store the numeric version of the computer's move
$robotChoiceNum #Computer's numeric choice
$robotChoiceWord #Computer's Word choice
$playerChoiceWord #Player's Word choice
$playerChoiceLet #Player's letter choice
$tie #Variable to keep track of tied games
$gamePlay $true #To control gameplay
$gamesPlayed #Number of games played
$gamesLost #Variable to keep track of the number of games lost
$gamesWon #Variable to keep track of games won
#Clears screen before beginning, writes welcome message on screen
cls
Writehost "Welcome to the n n vRock Paper, Scissors Game"
Writehost n v vPress Enter to continue"
$player ReadHost
StartSleep seconds ; ReadHost
while $gamePlay $true
cls
#Chooses a random number between and ; Rock Paper Scissors
$robotChoiceNum GetRandom Minimum Maximum
#Sets number to matching word
if $robotChoiceNum eq
$robotChoiceWord "Rock"
if $robotChoiceNum eq
$robotChoiceWord "Paper"
if $robotChoiceNum eq
$robotChoiceWord "Scissors"
while $playerChoiceLet
cls
WriteHost "Enter one of the following options:
$dash
WriteHost $dashn
WriteHost R Rock nP Paper nS Scissors nQ Quitn
WriteHost $dashn
#WriteHost "Make a move
# Validate player's move
$playerChoiceLet ReadHost "Make a move"
if $playerChoiceLet eq Q
ClearHost
WriteHost "Thank you for playing!"
$gamePlay $true
continue #Skip the remainder of the loop
elseif $playerChoiceLet notin RPS
WriteHost "Invalid input. Please try again."
$playerChoice ReadHost "Make your move:"
continue #Skip the remainder of the loop
switch $playerChoiceLet #Translate player's letter value to word value
R $playerChoiceWord "Rock"
P $playerChoiceWord "Paper"
S $playerChoiceWord "Scissors"
switch $playerChoiceWord #Compare the computer's and player moves to determine winner
R
switch $robotChoiceNum
WriteHost "It's a tie! Both chose Rock."
WriteHost "Computer wins! Paper beats Rock."
WriteHost "You win! Rock beats Scissors."
P
switch $robotChoiceNum
WriteHost "You win! Paper beats Rock."
WriteHost "It's a tie! Both chose Paper."
WriteHost "Computer wins! Scissors beat Paper."
S
switch $robotChoiceNum
WriteHost "Computer wins! Rock beats Scissors."
WriteHost "You win! Scissors beat Paper."
WriteHost "It's a tie! Both chose Scissors."
WriteHost n n "Results:
WriteHost $dashn
WriteHost "You picked: $playerChoiceWord
WriteHost "The computer picked: $robotChoiceWord
WriteHost $dashn
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
