Source of test_randomgenerator1.cpp


  1: //test_randomgenerator1.cpp
  2: //A test driver for the Scobey::RandomGenerator class.

  4: #include <iostream>
  5: using namespace std;

  7: #include "utilities.h"
  8: using Scobey::Pause;
  9: using Scobey::RandomGenerator;

 11: int main()
 12: {
 13:     Pause(0, "\nTesting the Scobey::RandomGenerator class ..."
 14:         "\n\nThis program is a very short example of using an object "
 15:         "of the RandomGenerator\nclass to get a sequence of pseudorandom "
 16:         "values (integers in this case) that\nchange with each run, and "
 17:         "a second sequence in which the values remain the\nsame on every "
 18:         "run of the program. For additional examples, including some\n"
 19:         "pseudorandom values of other data types, see the sample program "
 20:         "in the file\ntest_randomgenerator2.cpp");

 22:     Pause(0, "First we display some values that will be different on "
 23:         "each run.");
 24:     RandomGenerator g1;
 25:     for (int i=1; i<=20; i++) cout << g1.getNext(10) << " ";  cout << endl;
 26:     for (int i=1; i<=20; i++) cout << g1.getNext(10) << " ";  cout << endl;
 27:     Pause(0, "The above values will be different on each run.");

 29:     Pause(0, "Then we display some values that will be the same on "
 30:         "each run.");
 31:     RandomGenerator g2(10);
 32:     for (int i=1; i<=20; i++) cout << g2.getNext(10) << " ";  cout << endl;
 33:     for (int i=1; i<=20; i++) cout << g2.getNext(10) << " ";  cout << endl;
 34:     Pause(0, "The above values will be the same on each run.");

 36:     Pause(0, "No more tests to perform.\n"
 37:         "Program will now terminate.");
 38: }