HELP ME PLEASE WITH CLASSES

CAN SOMEONE PLEASE GIVE ME AN IN DEPTH ANSWER ON HOW THESE TWO CODES INTERACT WITH EACH. AN EXPLANATION ON WHAT IS GOING ON IN THIS PROGRAM. HOW EVERYTHING IS WORKING, HOW THIS WHOLE PROGRAM FUNCTIONS.


MY HEADER FILE
#ifndef DICE_H
#define DICE_H


#include<stdlib.h>
#include<time.h>

class dice{
public:

dice(int sides);

int roll();

int numrolls();

int numSides();

int rollings();

private:
int myRollCount;
int mySides;
};

dice::dice (int sides)

{
srand(unsigned(time(0)));
mySides = sides;
myRollCount = 0;
}

int dice::roll()
{
return (rand () %mySides)+1;// creates number between 1 and 6

}
int dice::rollings()
{
myRollCount++;
return myRollCount;
}

int dice::numrolls()
{
return myRollCount;
}

int dice::numSides()

{
return mySides;
}


#endif


HERE IS MY CPP FILE





#include <iostream>
#include <E:\dicetry2\dicetry2\dice2.h>
using namespace std;


int main()
{
dice die1(6), die2(6);
int loop = 0;
int counter = 2;
int sum = 0;
double percent = 0;
double solve = 0;


while (counter <= 12)
{
for(loop=1; loop <=1000; loop++)
{
sum = die1.roll() + die2.roll();

die1.rollings();

die2.rollings();

if (sum==counter){

percent++; } }

solve= percent/10;

cout<<counter <<"\t"<<percent<<"/1000\t"<<(percent/10)…

counter++;


percent = 0;}


cout<< die1.numrolls() << "\tFor die number 1" <<endl;

cout<< die2.numrolls() << "\tFor die number 2"<<endl;


system("pause");
return(0);
}
Topic archived. No new replies allowed.