I am in need of dire help. My Yahtzee game is due in class on Wednesday. My computer recently crashed and deleted my visual studios 2010 with all of my Projects that I have done. Luckily I had a back up file on my flash drive. Sad thing is though, I didn't have my recent work that I had accomplished from the past 6 days I was working on this. So my question is, can anyone help me make a good holdDie function/module and help me make a good scoring function/module as well? I really want to pass this class. Up until now I have a 91 A. This project is worth 25% of my grade. Can anyone please help me?
This is my ThingsThatNeverChange.h header
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <ctime>
#include <windows.h>
#include <conio.h>
#include <dos.h>
#include <math.h>
using namespace std;
char savenum = 'y';
char rollAgain = 'y';
int i;
const int Max_Rolls = 3;
int Rolls = 1;
const int TOTAL_DIE = 5;
int die[5]; // Random number generator array
int Hold[TOTAL_DIE]; // my current HoldDie function/module
int Rollsleft();
const int LOW = 1, HIGH = 6;
int Max_Turns = 13;
int Turns = 1;
int choice;
string name;
void gotoxy(int xpos, int ypos)
{
COORD scrn;
HANDLE hOuput = GetStdHandle(STD_OUTPUT_HANDLE);
scrn.X = xpos; scrn.Y = ypos;
SetConsoleCursorPosition(hOuput,scrn);
}
#define _WIN32_WINNT 0x0500
bool SetWindow(int Width, int Height);
bool SetWindow(int Width, int Height)
{
_COORD coord;
coord.X = Width;
coord.Y = Height;
_SMALL_RECT Rect;
Rect.Top = 0;
Rect.Left = 0;
Rect.Bottom = Height - 1;
Rect.Right = Width - 1;
// Get handle of the standard output
HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE);
if (Handle == NULL)
{
cout<<"Failure in getting the handle\n"<<GetLastError();
return FALSE;
}
// Set screen buffer size to that specified in coord
if(!SetConsoleScreenBufferSize(Handle, coord))
{
cout<<"Failure in setting buffer size\n"<<GetLastError();
return FALSE;
}
// Set the window size to that specified in Rect
if(!SetConsoleWindowInfo(Handle, TRUE, &Rect))
{
cout<<"Failure in setting window size\n"<<GetLastError();
return FALSE;
}
return TRUE;
}
This is my Scorecard.h header
#include <iostream>
#include <string>
#pragma region Rolls Left
int Rollsleft()
{
if (Rolls < Max_Rolls);
{
cout << "Rolls Remaining: " << Max_Rolls - Rolls << endl;
}
if(Rolls == Max_Rolls)
{
cout << "End Turn." << endl;
}
return 0;
}
#pragma endregion
int Turnsleft()
{
if (Turns < Max_Turns)
{
cout << "Turns left = " << Max_Turns - Turns << endl;
}
else if (Turns == Max_Turns)
{
cout << "Game Over" << endl;
}
return 0;
}
int TheDie()
{
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;
return 0;
}
void EndofTurn()
{
cout << "==============================================================================================" << endl;
cout << "= =" << endl;
cout << "= End of Turn =" << endl;
cout << "= =" << endl;
cout << "==============================================================================================" << endl;
}
void Scorecard()
{
cout << "==============================================================================================" << endl;
cout << "==============================================================================================" << endl;
cout << "= =" << endl;
cout << "= Yahtzee ScoreCard =" << endl;
cout << "= =" << endl;
cout << "==============================================================================================" << endl;
cout << endl;
cout << "==============================================================================================" << endl;
cout << endl;
cout << "==============================================================================================" << endl;
cout << "==============================================================================================" << endl;
cout << "= =" << endl;
cout << "= =" << endl;
cout << "= Aces Twos Threes Fours Fives Sixes Yahtzee =" << endl;
cout << "= =" << endl;
cout << "= =" << endl;
cout << "= Doubles Triples Four of a Kind Straight Full House Bonus Chance =" << endl;
cout << "= =" << endl;
cout << "= =" << endl;
cout << "==============================================================================================" << endl;
cout << "==============================================================================================" << endl;
cout << Rollsleft() << " =" << endl;
TheDie();
cout << "= You rolled a: " << die[0] <<" =" << endl;
cout << "= You rolled a: " << die[1] <<" =" << endl;
cout << "= You rolled a: " << die[2] <<" =" << endl;
cout << "= You rolled a: " << die[3] <<" =" << endl;
cout << "= You rolled a: " << die[4] <<" =" << endl;
cout << "==============================================================================================" << endl;
cout << "= =" << endl;
cout << "==============================================================================================" << endl;
}
void prompts()
{
gotoxy(10,8);
cout << "Type your name: ";
getline(cin,name);
gotoxy(17,29);
cout << "Do you want to re-roll? (y/n) ";
cin >> rollAgain;
if (rollAgain != 'y')
{
gotoxy(17,29);
cout << "Do you want to save any numbers? (y/n) ";
cin >> savenum;
if (savenum != 'y')
{
gotoxy(0,27);
EndofTurn();
}
else if (savenum == 'y')
{
gotoxy(17,29);
cout << " " << endl;
gotoxy(17,29);
cout << "What die do you want to save? ";
cin >> Hold[0];
}
gotoxy(17,29);
cout << " " << endl;
gotoxy(17,29);
cout << "Want to save another number? (y/n) ";
cin >> savenum;
if (savenum != 'y')
{
gotoxy(0,27);
EndofTurn();
}
else if (savenum == 'y')
{
gotoxy(17,29);
cout << " " << endl;
gotoxy(17,29);
cout << "What die do you want to save? ";
cin >> Hold[1];
}
gotoxy(17,29);
cout << " " << endl;
gotoxy(17,29);
cout << "Want to save another number? (y/n) ";
cin >> savenum;
if (savenum != 'y')
{
gotoxy(0,27);
EndofTurn();
}
else if (savenum == 'y')
{
gotoxy(17,29);
cout << " " << endl;
gotoxy(17,29);
cout << "What die do you want to save? ";
cin >> Hold[2];
}
gotoxy(17,29);
cout << " " << endl;
gotoxy(17,29);
cout << "Save another number? (y/n) ";
cin >> savenum;
if (savenum != 'y')
{
gotoxy(0,27);
EndofTurn();
}
else if (savenum == 'y')
{
gotoxy(17,29);
cout << " " << endl;
gotoxy(17,29);
cout << "What number do you want to save? ";
cin >> Hold[3];
}
gotoxy(17,29);
cout << " " << endl;
gotoxy(17,29);
cout << "Save one more number? (y/n) ";
cin >> savenum;
if (savenum != 'y')
{
gotoxy(0,27);
EndofTurn();
}
else if (savenum == 'y')
{
gotoxy(17,29);
cout << " " << endl;
gotoxy(17,29);
cout << "What number do you want to save? ";
cin >> Hold[4];
}
gotoxy(17,29);
cout << " " << endl;
gotoxy(17,29);
cout << "Your numbers are: " << Hold[0] << " , " << Hold[1] << " , " << Hold[2] << " , " << Hold[3] << " , " << Hold[4] << endl;
}
}
This is my main.cpp
#include "ThingsThatNeverChange.h"
#include "Scorecard.h"
#pragma region Main
int main()
{
srand(time(0));
Scorecard();
prompts();
system("pause");
return 0;
}
#pragma endregion