Question: Question: Add the ability to keep score to your RPS program from lab 6. Youll have to alter the function determineWinner so that it takes

Question: Add the ability to keep score to your RPS program from lab 6. Youll have to alter the function determineWinner so that it takes 2 additional parameters, userScore and computerScore that represent the number of wins for the user and computer respectively. Because one or the other of the new parameters will be altered inside the function, both should be declared as reference parameters .

My code I need help changing with the suggestions above:

#include  using namespace std; //declaration enum MOVE { Rock, Paper, Scissor}; //function void showInstructions() { cout<<"------Welcome to Rock Paper Scissor game------ "; cout<<"User should enter R or r for Rock P or p for Paper S or s for Scissor "; } //function MOVE getUserMove() { char c; bool valid = true; enum MOVE userMove; while(valid == true) { cout<<"Your Move:"; cin>>c; if(c=='R' || c=='r') { userMove = Rock; valid = false; } else if(c=='P' || c=='p') { userMove = Paper; valid = false; } else if(c=='S' || c=='s') { userMove = Scissor; valid = false; } else { valid = true; cout<<"Enter valid move "; } } return userMove; } //function MOVE getComputerMove() { int n = rand()%3; return (MOVE)n; } //function void getWinner(MOVE u,MOVE c) { if(u==c) { cout << "It's a tie!!"; cout << "Computer chose same move"; } else if(u==0 && c==2) { cout << "You won!!"; cout << "Computer chose Scissors "; } else if(u==1 && c==0) { cout << "You won!!"; cout << "Computer chose Rock"; } else if(u==2 && c==1) { cout << "You won!!"; cout << "Computer chose Paper"; } else cout<<"Computer won!!"; } //function bool playAgain() { char c; bool valid = true; bool choice; while(valid == true) { cout<<"Do you want to play again?(y/n):"; cin>>c; if(c=='Y' || c=='y') { choice = true; valid = false; } else if(c=='N' || c=='n') { choice = false; valid = false; } else { cout<<"Enter valid move!! "; valid = true; cin.clear(); cin.ignore(10000, ' '); } } return choice; } //main function int main() { //infinite loop do { //calling functions showInstructions(); enum MOVE c = getComputerMove(); enum MOVE u = getUserMove(); getWinner(u,c); }while(playAgain()); return 0; } 

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 Databases Questions!