Need help with a program

Write your question here.

Hi everyone,

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!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
 * 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;
}
Last edited on
1
2
3
4
5
string getName; // Variable

getName = "iman972"; // Variable getName is now equal to iman972

int player_number = 1 || 2; // ??? You are using OR incorrectly 


I think you have misunderstood some basic concepts, try this link: http://www.cplusplus.com/doc/tutorial/variables/

If I wanted to create a player 1 and a player 2, how would i set player_number to 1 OR 2?
Topic archived. No new replies allowed.