Answered step by step
Verified Expert Solution
Question
1 Approved Answer
it has to be in java play(userSelection) This method takes in 1 parameter: the user Selection. It will: Get the CPU Random selection using the
it has to be in java
play(userSelection) This method takes in 1 parameter: the user Selection. It will: Get the CPU Random selection using the generateCPUResponse() Determine the winner using the determineWinner(user Selection, cpuSelection) update the score tally this.score // if the user won the round this.score.user ++; // if the user cpu the round this.score.cpu ++; OR this.score = { user: NEW_SCORE, cpu: NEW_SCORE Add another historyLog entry to the game history array. the log entry should look something like this Ben selected Scissors, CPU selected Paper: Ben wins wins this gameHistoryLog.push("Ben selected Scissors, CPU selected Paper: Ben wins wins"); generateCPUResponse() For this function: 1 Create an array with the following values const acceptedValues = [ 'rock, 'paper", 'scissors ] 2 Using both Math.random and Math.floor() methods, generate a random index number (0,1,2) 3 return the value of acceptedValue at the random index generated in the previous stepStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started