// p7.cpp -- driver program to illustrate use of the contextIndex class #include "ContextIndex.cpp" // templated ContextIndex that you must write #include "Card.h" // class of Cards that you must write #include #include #include #include // for random #include // for time for random seeding using namespace std; int rand(int, int); // to generate random integers in range int main() { srand(time(NULL)); // seed random number generator with time now ContextIndex cii(500,3); ofstream numfile("numfile.txt"); numfile << rand(400, 700); for (int i=1; i < 25; i++) numfile << ' ' << rand(400, 700); numfile.close(); ifstream infile("numfile.txt"); infile >> cii; infile.close(); cii.build(); cout << "Collection: " << cii.collection() << endl; cout << "--------------------------------------" << endl; cout << "integer context index "; cout << cii; const Card mincard(10, "Diamonds"); ContextIndex cci(mincard); string filename; cout << "enter name of Card text file: "; cin >> filename; infile.open(filename.c_str()); infile >> cci; infile.close(); cci.build(); ofstream ofile; ofile.open(filename.c_str(), ios::app); ofile << "Collection: " << cci.collection() << endl; ofile << "--------------------------------------" << endl; ofile << "Card context index "; ofile << cci; ofile.close(); return 0; } int rand(int low, int high) // return random integer in range [low,high] inclusive { if (low>high) // error checking/dummy proofing { int temp=low; low = high; high = temp; } return rand()%(high-low+1) + low; }