Yahtzee part 1

I have to write the first "part" of the game Yahtzee to include three functions (other than main); RollDice, DisplayBoard, and Keepers. Here are the instructions -

Write a program that will simulate rolling and storing the values of 5 dice. Display the values of the rolls; allow the user to select the values to keep and which to re-roll. Re-roll the needed dice and re-display. Repeat this process again for a maximum of 3 possible rolls.

Here is my code so far;

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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include <iostream>
#include "dice.h"
using namespace std;

const int DICE_CNT = 5;
const int NUM_ROLL = 3;
const int NUM_SIDES = 6;

void RollDice (int myDie[DICE_CNT], bool Keep [DICE_CNT]) {
	// rolls dice and uses Keepers to determine which dice to keep and which to roll again
	
	Dice die (NUM_SIDES);
	int count;
		
		for (count = 0; count < DICE_CNT; count ++) {
			if (Keep [count])
				myDie [count] = die.Roll ();
                                cout << myDie [count] << "\t";
		}
}


void Keepers (bool Keep [DICE_CNT]) {
	// asks users which dice they want to keep

	char yesNo;

		cout << endl << "Would you like to keep die #1? (y/n): ";
			cin >> yesNo;
				if (yesNo = 'y')
					Keep [0] = true;
			cout << endl;
		
		cout << "Would you like to keep die #2? (y/n): ";
			cin >> yesNo; 
				if (yesNo = 'y')
					Keep [1] = true;
			cout << endl;

		cout << "Would you like to keep die #3? (y/n): ";
			cin >> yesNo;	
				if (yesNo = 'y')
					Keep [2] = true;
			cout << endl;

		cout << "Would you like to keep die #4? (y/n): ";
			cin >> yesNo;
				if (yesNo = 'y')
					Keep [3] = true;
			cout << endl;

		cout << "Would you like to keep die #5? (y/n): ";
			cin >> yesNo;
				if (yesNo = 'y')
					Keep [4] = true;
			cout << endl;

}

int main () {
	// runs DisplayBoard and Keepers
	
	char yesNo;
	int myDie [DICE_CNT];
	bool Keep [DICE_CNT];
	int dcnt;
	int rcnt;

	for (dcnt = 0; dcnt <= DICE_CNT; dcnt ++){
		Keep [DICE_CNT] = false;
	}
	
	for (rcnt = 0; rcnt < NUM_ROLL; rcnt ++) {
		RollDice (myDie, Keep);
		cout << endl << "Would you like to keep any of your dice? (y/n): ";
			cin >> yesNo;
			if (yesNo == 'y') {
				cout << endl;
				Keepers (Keep);
			}
	}

return 0;
}


I don't know what I'm doing wrong but it keeps giving me the error msg "stack around variable Keep was corrupted." What does that mean? And I havent created DisplayBoard yet because I cant figure out how to get it to only display the dice that need to be rolled again?
Topic archived. No new replies allowed.