Question: C++ CODE THAT MUST BE IMPLEMENTED INTO : Pageof 3 ZOOM #include using namespace std; void ClearScreen(); string GetName(string prompt); string GetMove(); int CompareMoves(string move1,
C++
CODE THAT MUST BE IMPLEMENTED INTO :
Pageof 3
ZOOM
#include
using namespace std;
void ClearScreen();
string GetName(string prompt);
string GetMove();
int CompareMoves(string move1, string move2);
void PlayOneRound(string player1, string player2, int & score1, int &
score2);
void PlayAllRounds(int numRounds, string player1, string player2);
void PlayRPS();
int InputInt();
void ClearScreen()
{
// TO DO:
// (1) Simulate clearing the screen by printing 50 blank lines.
// Hint - You should use a for loop for this!
// Please do NOT use a specific operating system command
// that actually clears the screen.
}
string GetName(string prompt)
{
// TO DO:
// (1) Print the prompt specified by the prompt parameter
// (2) Input an entire line from the user
// (3) Do input validation, repeating the prompt and input if the
user
// enters an empty line
// (4) Return the string the user entered
}
string GetMove()
{
// TO DO:
// (1) Prompt the user with "Pick a move -- rock, paper, or
scissors: " and input a string.
// (2) Do input validation, repeating the input step if the user
doesn't pick a valid choice.
// (3) Return the item the user picked.
}
int CompareMoves(string move1, string move2)
{
// TO DO:
// (1) Compare move1 with move2, determining which one "beats" the
other,
// based on standard rock-paper-scissors rules.
// Each parameter will already be set to "rock" or "paper" or
"scissors".
//
// (2) Return a single int indicating the result:
// 0 for a tie, 1 if move1 beats move2, 2 if move2 beats
move1.
}
void PlayOneRound(string player1, string player2, int & score1, int &
score2)
{
cout
cout
// TO DO:
// (1) By calling the GetMove function, get player 1's move and
store it in a variable
ClearScreen();
cout
cout
// TO DO:
// (2) By calling the GetMove function, get player 2's move and
store it in a variable
// (3) By calling the CompareMove function, get information about
the winner of this round
// and store it in a variable.
ClearScreen();
// TO DO:
// (4) Print a line of output to summarize what happened in this
round, using
// the result from (3). This should follow this sequence of
formats:
// "____ played ____."
// "____ played ____."
// "____ won!" (Or "It was a tie.")
// (5) If one of the player's one this round, increment the
corresponding score.
}
void PlayAllRounds(int numRounds, string player1, string player2)
{
// NOTE: This function is ALREADY COMPLETE. No additions needed!
// Variables for the players' scores
int player1score = 0;
int player2score = 0;
for (int i = 1; i
{
cout
cout
cout
PlayOneRound(player1, player2, player1score,
player2score);
}
cout
cout
cout
cout
}
void PlayRPS()
{
// NOTE: This function is ALREADY COMPLETE. No additions needed!
// Variables for the players' names
string name1 = "";
string name2 = "";
// Variable for the number of rounds
int userRounds = 0 ;
// Here we set up variables by asking the user some questions
name1 = GetName("First player, what is your name? ");
name2 = GetName("Second player, what is your name? ");
cout
userRounds = InputInt();
// Now we call PlayAllRounds() to handle the actual rounds
PlayAllRounds(userRounds, name1, name2);
}
int InputInt()
{
// NOTE: This function is ALREADY COMPLETE. No additions needed!
int userInput;
cin >> userInput;
/// input validation
while (cin.fail())
{
cin.clear();
cin.ignore(1000, ' ');
cout
cin >> userInput;
}
cin.ignore(1000, ' ');
return userInput;
}
Secure https//dlpootdinstructure.com/courses/6803/assignments/2T7583 PA6: Top-Down Design Due Mar 13 by 11:59pm Points 20 Submitting a fle upload File Types cpp bus Overall Instructions ules nments ussions Unlike all previous assignments, for this assignment you will NOT submit a main0. You will still submit one.cpp file, but it will contain only prototypes and definitions for specific functions specified in the assignment. My grading procedure for this assignment involves testing each of your functions prototypes 0. must match what is specified here, or I will not be able to compile with my testing code and you will receive a project. Use this to write testing commands that call the As you work on your code, you should have a main) in your functions you are creating to make sure they work. However, you will submit a copy of your code without your main) in the file. tt Discover Part I: Rock, Paper Scissors For this part of the assignment, you will take-starter code" that l provide and add code to it in order to implement a C++ version of "Rosk. Paper. Scissorse': where 2 players play a certain number of rounds, and then a winner is declared. The starter code is already designed modularly: it is broken up into separate functions that perform independent pieces of the overall task The starting code for this task is here: ms.coR You should start by reading through it thoroughly. Notice that the function PlayRPS0 is the one that actually "runs the whole game, calling other functions in the process Important advice I strongly recommend that you write code in the order it is listed, from top to bottom. All of the code that already exists is there for a reason. You should not remove or change any of it Add code to each portion of code labeled TO DO according to the instructions in the comments Extra Cred For a small amount of extra credit and fun, change your code so that instead of Rock, Paper. Scissors it lets the two players play "Rock, Paper. Scissors, Lizard, Spock as explained bsrse for many other places on the internet)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
