G
Guest
Hello,
I have created a class called Die and an implementaion of Die (ex. to
follow) where the default generates a NEW digit 1-6.
I am creating a dice game wherein: a die is rolled (Roll_ 1) then the user
is asked to guess if Roll_2 will be higher or lower than Roll_1.
Without showing the rest of this riduclous project, my issue is that the new
objects Roll_1 & Roll_2 are the same number in the comparison.
However, when I go through the game a second time (the user can play again),
a different number is generated for Roll_1, yet again Roll_2 is the same.
Implemenation code:
Die:ie() {
int roll;
srand((unsigned int)time(0));
do {
roll = 1 + rand()%6;
}while (roll <= 0);
Set_FaceUp(roll);
}
Driver Code:
Die Roll_1;
Die Roll_2;
Any advice would be appreciated, I'm stuck! Thanks
I have created a class called Die and an implementaion of Die (ex. to
follow) where the default generates a NEW digit 1-6.
I am creating a dice game wherein: a die is rolled (Roll_ 1) then the user
is asked to guess if Roll_2 will be higher or lower than Roll_1.
Without showing the rest of this riduclous project, my issue is that the new
objects Roll_1 & Roll_2 are the same number in the comparison.
However, when I go through the game a second time (the user can play again),
a different number is generated for Roll_1, yet again Roll_2 is the same.
Implemenation code:
Die:ie() {
int roll;
srand((unsigned int)time(0));
do {
roll = 1 + rand()%6;
}while (roll <= 0);
Set_FaceUp(roll);
}
Driver Code:
Die Roll_1;
Die Roll_2;
Any advice would be appreciated, I'm stuck! Thanks