谁能根据下面的文件,帮我编一个"RandomInt"类?
这是清华大学出版社的《C++大学教程(第三版)》205页的例题,谁有这本书的帮我做更好。
我不知道该怎样创建那个"RandomInt"类```书上没教怎样创建```。
/***
,
计算特定点数出现的次数
输入:掷股子的次数
输出:用户提示,点数的相对频率
**/
#include <iostream>
#include "RandomInt.h"
using namespace std;
int main()
{
cout <<"This program simulates a given number of dice-pair rolls,\n"
<<"counting the number of times a given roll occurs.\n";
int numberOfRolls; //点数次数
cout <<"\nHowmany times are the dice to be rolles?";
cin >>numberOfRolls;
RandomInt die1(1,6), //第一个股子
RandomInt die2(1,6); //第二个
int pair, //两个
numberOfSpots, //得到的点数
occurrences; //抛掷次数
cout <<"Enter number of spots to cout (2-12,0 to stop):";
cin >>numberOfSpots;
while (numberOfSpots !=0) //输入循环
{
occurrences=0; //将计算器设为0
//反复执行循环
for (int rollCount =1) //接下来
rollCount <=numberOfRolls;//次数
rollCount++; //开始
pair+die1.generate()+die2.generate();
if (pair==numberOfSpots) //特定点数出现
occurrences++; //计数器计数
} //循环结束
//显示结果
cout <<"The relative frequency of" <<numberOfSpots
<<"was" <<double (occurrences)/double (numberOfRolls) <<"\n\n";
cout <<"Enter number of spots to count (2-12, 0 to stop):";
cin >>numberOfSpots;
return 0;
}