I am very new to coding and i am in a c++ class that I am struggling in. We were assigned a rock, paper, scissors program to make and I am completely stuck on how to use the string getName. The first part of the program wants us to ask the name of each player. We were given a skeleton of the code to work with which had some explanation in it. Also every time i try to run this I get a break exception box that pops up. Please help!
/**
* Requires: player_number is either 1 or 2.
* Modifies: Nothing.
* Effects : Prompts the user to enter their name. Names may have spaces
* within them. Example: Kermit the Frog, Fozzie
* If an empty name is given, print error message 1, and
* return a default name.
* For player 1, the default name is: Rocky
* For player 2, the default name is: Hulk
* Prompt : Player [player_number], enter your name:
* Used In : main()
*/
string getName(int player_number);
int main() {
int player_number = 1 || 2;
string getName(int player_number);
// Print the header
printInitialHeader();
// Get the player names
cout << "Player 1, enter your name : " << getName(1) << endl;
cout << "Player 2, enter your name : " << getName(2) << endl << endl;
// Simulate the first 2 rounds
// Check if either player already clinched a win:
// If they have, announce the winner.
// Otherwise, simulate the third round, find who has more wins,
// and announce the winner.
return 0;
}
void printInitialHeader() {
cout << "----------------------------------------" << endl;
cout << " EECS 183 " << endl;
cout << " Rock-Paper-Scissors " << endl;
cout << "----------------------------------------" << endl << endl;
}
string getName(int player_number){
cin >> getName(player_number);
player_number = 1 || 2;
return 0;
}
string getName; // Variable
getName = "iman972"; // Variable getName is now equal to iman972
int player_number = 1 || 2; // ??? You are using OR incorrectly