I have many things done so far in my project. However, in my switch statement it does not generate random numbers like it did earlier. You'll see what I mean. Other than that I need help with the scoring part of the assignment. Can anyone please help me? I feel like I am close to being finished with my programming I class final...Yahtzee.
Here is the code:
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
using namespace std;
void Welcome_Screen()
{
cout << " \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ " << endl;
cout << endl;
cout << " Yahtzee Scorecard Edition " << endl;
cout << endl;
cout << " \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ " << endl;
cout << endl;
cout << endl;
cout << endl;
cout << "Brought to you by Subway.....Eat Fresh!" << endl;
cout << endl;
cout << endl;
system("pause");
}
void Board()
{
string name, letter;
int randomnumber = rand();
system("cls");
cout << "================================================" << endl;
cout << endl;
cout << " Player Scorecard" << endl;
cout << endl;
cout << "================================================" << endl;
cout << endl;
cout << "Type in your name: ";
getline(cin,name);
cout << endl;
cout << "Enter d to roll the die: ";
cin >> letter;
cout << endl;
cout << "_________________________________________________" << endl;
cout << endl;
}
void Roll_Again_With_Features()
{
char numbersave = 'y';
char rollAgain = 'y';
char savenum = 'y';
const int LOW = 1, HIGH = 6;
int Die[5], die[5], choice;
die[0] = rand() % (HIGH - LOW + 1) + LOW;
die[1] = rand() % (HIGH - LOW + 1) + LOW;
die[2] = rand() % (HIGH - LOW + 1) + LOW;
die[3] = rand() % (HIGH - LOW + 1) + LOW;
die[4] = rand() % (HIGH - LOW + 1) + LOW;
cout << "Your numbers are: " << die[0] << endl;
cout << "Your numbers are: " << die[1] << endl;
cout << "Your numbers are: " << die[2] << endl;
cout << "Your numbers are: " << die[3] << endl;
cout << "Your numbers are: " << die[4] << endl;
cout << "_________________________________________________" << endl;
cout << endl;
do
{
cout << "Roll Again?? (y/n): ";
cin >> rollAgain;
cout << endl;
if (rollAgain != 'y')
{
cout << "Do you want to save any numbers? (y/n): ";
cin >> savenum;
if (savenum != 'y')
{
cout << " End of Turn" << endl;
}
else if (savenum == 'y')
{
cout << "What number do you want to save? (1-6): ";
cin >> Die[0];
cout << endl;
cout << "Do you want to save any other number? (y/n): ";
cin >> numbersave;
if (numbersave != 'y')
{
cout << endl;
}
else if (numbersave == 'y')
{
cout << "What number do you want to save? (1-6): ";
cin >> Die[1];
cout << endl;
}
cout << "Save another number? (y/n): ";
cin >> savenum;
if (savenum != 'y')
{
cout << endl;
}
else if (savenum == 'y')
{
cout << "What number do you want to save? (1-6): ";
cin >> Die[2];
cout << endl;
cout << "Do you want to save another? (y/n): ";
cin >> numbersave;
if (numbersave != 'y')
{
cout << endl;
}
else if (numbersave == 'y')
{
cout << "What number do you want to save? (1-6): ";
cin >> Die[3];
cout << endl;
}
}
cout << "Save another number? (y/n): ";
cin >> savenum;
if (savenum != 'y')
{
cout << endl;
}
else if (savenum == 'y')
{
cout << "What number do you want to save? (1-6): ";
cin >> Die[4];
cout << endl;
cout << "Your Die are: " << Die[0] << " " << Die[1] << " " << Die[2] << " " << Die[3] << " " << Die[4] << endl;
}
}
}
else if (rollAgain == 'y')
{
cout << "Do you want to save any numbers before you re roll? (y/n): ";
cin >> savenum;
if (savenum != 'y')
{
cout << "How many die do you want to re roll? ";
cin >> choice;
switch (choice)
{
case 1:
cout << "You rolled a: " << die[0] << endl;
break;
case 2:
cout << "You rolled a : " << die[0] << " , " << die[1] << endl;
break;
case 3:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << endl;
break;
case 4:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << " , " << die[3] << " , " << die[4] << endl;
break;
case 5:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << " , " << die[3] << " , " << die[4] << " , " << die[5] << endl;
break;
}
}
else if (savenum == 'y')
{
cout << "What number do you want to save? (1-6): ";
cin >> Die[0];
cout << endl;
cout << "Do you want to save any other number? (y/n): ";
cin >> numbersave;
if (numbersave != 'y')
{
cout << "How many die do you want to re roll? ";
cin >> choice;
switch (choice)
{
case 1:
cout << "You rolled a: " << die[0] << endl;
break;
case 2:
cout << "You rolled a : " << die[0] << " , " << die[1] << endl;
break;
case 3:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << endl;
break;
case 4:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << " , " << die[3] << " , " << die[4] << endl;
break;
case 5:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << " , " << die[3] << " , " << die[4] << " , " << die[5] << endl;
break;
}
}
else if (numbersave == 'y')
{
cout << "What number do you want to save? (1-6): ";
cin >> Die[1];
cout << endl;
}
cout << "Save another number?? (y/n): ";
cin >> numbersave;
if (numbersave != 'y')
{
cout << "How many die do you want to re roll? ";
cin >> choice;
switch (choice)
{
case 1:
cout << "You rolled a: " << die[0] << endl;
break;
case 2:
cout << "You rolled a : " << die[0] << " , " << die[1] << endl;
break;
case 3:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << endl;
break;
case 4:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << " , " << die[3] << " , " << die[4] << endl;
break;
case 5:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << " , " << die[3] << " , " << die[4] << " , " << die[5] << endl;
break;
}
}
else if (numbersave == 'y')
{
cout << "What number do you want to save? (1-6): ";
cin >> Die[2];
cout << endl;
}
cout << "Do you want to save any other number? (y/n): ";
cin >> numbersave;
if (numbersave != 'y')
{
cout << "How many die do you want to re roll? ";
cin >> choice;
switch (choice)
{
case 1:
cout << "You rolled a: " << die[0] << endl;
break;
case 2:
cout << "You rolled a : " << die[0] << " , " << die[1] << endl;
break;
case 3:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << endl;
break;
case 4:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << " , " << die[3] << " , " << die[4] << endl;
break;
case 5:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << " , " << die[3] << " , " << die[4] << " , " << die[5] << endl;
break;
}
}
else if (numbersave == 'y')
{
cout << "What number do you want to save? (1-6): ";
cin >> Die[3];
cout << endl;
}
cout << "Save another number?? (y/n): ";
cin >> numbersave;
if (numbersave != 'y')
{
cout << "How many die do you want to re roll? ";
cin >> choice;
switch (choice)
{
case 1:
cout << "You rolled a: " << die[0] << endl;
break;
case 2:
cout << "You rolled a : " << die[0] << " , " << die[1] << endl;
break;
case 3:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << endl;
break;
case 4:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << " , " << die[3] << " , " << die[4] << endl;
break;
case 5:
cout << "You rolled a: " << die[0] << " , " << die[1] << " , " << die[2] << " , " << die[3] << " , " << die[4] << " , " << die[5] << endl;
break;
}
}
else if (numbersave == 'y')
{
cout << "What number do you want to save? (1-6): ";
cin >> Die[4];
cout << endl;
cout << "Your Die are: " << Die[0] << " , " << Die[1] << " , " << Die[2] << " , " << Die[3] << " , " << Die[4] << endl;
}
}
}
} while (rollAgain == 'y');
cout << endl;
}
int main()
{
srand(time(0));
Welcome_Screen();
Board();
Roll_Again_With_Features();
system("pause");
return 0;
}
Thank you again for your help guys =)