Doing this project 1 step @ a time but the multiple files are starting to get confusing. Lemme start by telling you all what I need to do, then show you what I've done, and then maybe you can tell me if I'm on track with this or if I need to scrap it and start over. I don't necessarily want you to give me any code - I can do my own homework, but a point in the right direction.
Simulate Dice Rolling Game
1. Two classes used (Die, DiceRoll)
Note: Die is an abstraction of a single physical entity
DiceRoll is an abstraction of three dice rolled together
DiceRoll contains no constructor member function
class Die and class DieRoll must be in separate files
2. Three global functions required
void GatherStats(int RollsArray[], int RollsArraySize, int ResultsArray[]); // prototype
3. Loop for the size of the RollsArray include switch
Note: case clause increment ResultsArray cell, count all possible dice rolls
Frequency of each total is recorded in ResultsArray
4. Main driver global function declare two arrays and call the gloval functions
Note: Min size of 200
5. Pass RollsArray to GatherStats function and call DisplayResults
6. Display a horizontal histogram of asterisk characters.
7. Display a vertical histogram of asterisk characters.
Code(This is broken up into multiple files cuz it's easier to work on and compile.)
Dice.h
#ifndef DieRoll // allows for additional
#define DieRoll
class Die
{
public: // available outside of class
Die(); // SMF to set value
void Roll(); // member functions
int GetFaces();
private: // not available outside class
int Face;
};
#endif
Dice.cpp
#include <iostream> // for cin,cout
#include <cstdlib> // for the library rand() function
#include <cmath>
#include <ctime>
using std::cout;
using std::cin;
using std::endl;
Die::Die() //Initializes Face data member
{
Face = 1,2,3,4,5,6;
}
void Die::Roll() //Sets Face to a randomly generated number 1-6
{
srand(time_t(NULL));
}
int Die::GetFaces() // returns the die face value
{
return rand() %6 + 1;
}
DiceRoll.h
class DiceRoll // classs that specifies a collection of 3 contained Die objects
{
public:
void RollDice(); // Calls Roll() function on each contained die
int GetRollFaces(); // Returns the sum of the current Face value of Die1, Die2, & Die3
private:
Die Die1; // The three die contained in this -i.e
Die Die2; // objects of this class automatically contain
Die Die3; // three dice
};
Function.h
void GatherStats(int RollsArray[], int RollsArraySize, int ResultsArray[]); // 3 global functions
#endif
Function.cpp (mostly pseudo-code at this point)
using std::cout;
using std::cin;
using std::endl;
void GatherStats(int RollsArray[], int RollsArraySize, int ResultsArray[])
{
for (int i =0;i < RollsArraySize; i++)
{
switch (RollsArray[i])
{
case 3: ResultsArray[0]=ResultsArray[0]+1; break;
case 4: ResultsArray[1]=ResultsArray[1]+1; break;
}
}
}