本文整理汇总了C++中Dice::Roll方法的典型用法代码示例。如果您正苦于以下问题:C++ Dice::Roll方法的具体用法?C++ Dice::Roll怎么用?C++ Dice::Roll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dice
的用法示例。
在下文中一共展示了Dice::Roll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
const int start=1;
const int stop=12;
int storeroll[13]; // this is an array declaration for an array of 12 integers
//storeroll[0]=0; // this will remain unused, but we can initialize it.
int loopcount =1;
Dice cube; // make a six-sided die
cube.Roll(); //For debugging purposes, the same number will be generated by EVERY SINGLE first roll.
//So, unless you want the same number for each first roll, we must throw away the first roll.
//which we do by ignoring the first roll and not storing it or printing it out.
storeroll[0] = cube.Roll();
cout << storeroll[0] << endl;
cout << "This loop displays "<<stop-start+1 <<" rolls of a 6-sided dice:\n" << endl;
for (loopcount=start; loopcount<=stop; loopcount++)
{
storeroll[loopcount]=cube.Roll(); // put the roll into the array
cout << "Roll " <<loopcount<< " is " << storeroll[loopcount] << "."<< endl;
}
cout << "\nRolled the six-sided dice " << cube.NumRolls()-1 << " times.\n" << endl;
return 0;
}
示例2:
TEST (Dice, CanInjectRangeAfterInstantiaton)
{
Dice dice;
dice.Ranged (Range(1,2));
EXPECT_LE (1, dice.Roll());
EXPECT_GE (2, dice.Roll());
}
示例3: range
TEST (Dice, DiceRollsWithGivenRange)
{
Range range (1,6);
Dice dice (range);
EXPECT_LE (1, dice.Roll());
EXPECT_GE (6, dice.Roll());
}
示例4: dice
TEST (Dice, RollSome5Result)
{
Dice dice (Range (1,2));
for (int i=0; i<5; i++)
dice.Roll();
}