/****************************************************** ** Name: ** Filename: PseudoRandomDrv.cpp ** Project #: Data Structures And Other Objects Using C++ 2nd Edition (Micheal Main & Walter Savich) ** Project Description: Design and implement a class that can generate a pseudorandom sequence. Perform test of the class for working results ** Output: A user defined length for pseudorandom sequence of numbers ** Input: Input the number of times to test PseudoRandom class. ** Algorithm: Design PseudoRandom class with two functions. function Init to initialize the first of the pseudorandom numbers. function NextNum to return the next number that becomes the seed to create next random number. Design driver PseudoRandomDrv to test class Pseudorandom. ******************************************************/ // Include files #include #include #include #include "PseudoRandom.h" using namespace std; // Global Type Declarations // Function Prototypes void instruct (void); void pause (); //Global Variables - should not be used without good reason. int main() { // Declaration section PseudoRandom p; int runs = 0; // Executable section instruct (); // Initialize the pseudorandom number using the Init function p.Init(1, 40, 725, 729); cout << "Enter number of times to run test of PseudoRandom " << "class: " ; cin >> runs; // Testing functions in PseudoRandom class for (int i = 1; i <= runs; i++) cout << "\nNumber " << i << " = " << p.NextNum() << endl; pause (); return 0; } void instruct (void) { // Declaration section cout << "This is a test driver to test the class PseudoRandom " << "which creates a sequence\nof pseudorandom numbers. " << "Please enter the number of integers to create in the\n" << "generated pseudorandom sequence of numbers. \n" << "----------------------------------------------------" << "---------------------------" << endl; // Executable section } void pause () { // Declaration section // Executable section cout << "\nPress any key to continue..."; getch(); cout << "\r"; cout << " "; cout << "\r"; } /* Program Output The is a test driver to test the class PseudoRandom which creates a sequence of pseudorandom numbers. Please enter the number of integers to create in the generated pseudorandom sequence of numbers. ------------------------------------------------------------------------------- Enter number of times to run test of PseudoRandom class: 5 Number 1 = 36 Number 2 = 707 Number 3 = 574 Number 4 = 357 Number 5 = 425 Press any key to continue... */