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; }
TEST (Dice, CanInjectRangeAfterInstantiaton) { Dice dice; dice.Ranged (Range(1,2)); EXPECT_LE (1, dice.Roll()); EXPECT_GE (2, dice.Roll()); }
TEST (Dice, DiceRollsWithGivenRange) { Range range (1,6); Dice dice (range); EXPECT_LE (1, dice.Roll()); EXPECT_GE (6, dice.Roll()); }
TEST (Dice, RollSome5Result) { Dice dice (Range (1,2)); for (int i=0; i<5; i++) dice.Roll(); }