adding two dice - functions

This is my function:

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
50
51
52
53
54
55
void displayDice()
{
	int dieRoll = distribution(generator);//randomly generates a number from 1 to 6

	if (dieRoll == 1)
	{
		cout << " ------- " << endl;
		cout << "|       |" << endl;
		cout << "|   o   |" << endl;
		cout << "|       |" << endl;
		cout << " ------- " << endl;
	}
	else if (dieRoll == 2)
	{
		cout << " ------- " << endl;
		cout << "| o     |" << endl;
		cout << "|       |" << endl;
		cout << "|     o |" << endl;
		cout << " ------- " << endl;
	}
	else if (dieRoll == 3)
	{
		cout << " ------- " << endl;
		cout << "|     o |" << endl;
		cout << "|   o   |" << endl;
		cout << "| o     |" << endl;
		cout << " ------- " << endl;
	}
	else if (dieRoll == 4)
	{
		cout << " ------- " << endl;
		cout << "| o   o |" << endl;
		cout << "|       |" << endl;
		cout << "| o   o |" << endl;
		cout << " ------- " << endl;
	}
	else if (dieRoll == 5)
	{
		cout << " ------- " << endl;
		cout << "| o   o |" << endl;
		cout << "|   o   |" << endl;
		cout << "| o   o |" << endl;
		cout << " ------- " << endl;
	}
	else
	{
		cout << " ------- " << endl;
		cout << "| o   o |" << endl;
		cout << "| o   o |" << endl;
		cout << "| o   o |" << endl;
		cout << " ------- " << endl;
	}

	return;
}


I'm supposed to call it twice from main and then add the randomly generated numbers together. How do you do this?
You could have the dice roll function return the actual roll result instead of void.
Like Ispil said... Throw in some return statements in your "if"-statements and return that value to a summed value in main.
Topic archived. No new replies allowed.