/* Proj1.C Project 1, CMSC-341, Spring, 2001 This file contains the main function. Mitch Edelman Created: January 22, 2001 Current: */ #include "Set.H" #include "Proj1_aux.H" #include // for random #include #include #include // Command line argument is an int, the number of // elements to be inserted in the Sets. int main(int argc, char **argv) { int i; // Read the number of elements from the command line if(argc !=3) { cerr << "Invalid number of command line arguments\n" << "Usage is Prog1 ]n" << "Aborting" < set1; cout << "Set1 = " << set1 < set2; set2 = set1; cout << "set2 = " << set2 << endl; cout << " --- " << "Removing 3 from set1 (if there)" << endl; set1 = set1 - (3); cout << "set1 = " << set1 << endl; cout << "set2 = " << set2 << endl; } cout << " --- " << "Making set1 empty" << endl; set1.MakeEmpty(); cout << "set1 = " << set1 << endl; cout << " --- " << "Constructing Set of strings strSet"; cout << endl; Set strSet; string FileName = getFileName(argc, argv); ifstream Infile (FileName.c_str(), ios::in); if (! Infile){ cerr<<"cannot open " << argv[2] << " for input" < strSet2; strSet2 = strSet2 + "george"; strSet2 = strSet2 + "Al"; cout << "\n\n\n\ntesting set equality on string sets" << endl; if (strSet2 == strSet) cout << "StrSet2 == strSet" << endl; else cout << "StrSet2 != StrSet1" << endl; cout << " Testing set union on string sets" << endl; Set strSet3; strSet3 = strSet3 + "Bill"; cout << "Set 2 = " << strSet2 << endl; cout << "Set 3 = " << strSet3 << endl; cout << "Union = " << strSet2 + strSet3 << endl; cout << "\n\n\n\nTesting Set Intersection on sets of strings\n"; cout << "Next Intersection should be empty" << endl; cout << "set2 *set3 = " << strSet2 * strSet3 << endl; cout << "\n\n\n\nA more interesting intersection test " << endl; strSet2 = strSet2+"Max"; strSet3 = strSet3 + "Max"; cout << "Set2 = " << strSet2 << endl << "\tSet3 = " << strSet3 << endl; cout << "Set2 * Set3 = " << strSet2 * strSet3 << endl; cout << "\n\n\n\nTest Set Difference " << endl; cout << "Subtract set from itself - should get empty set" << endl; cout << "set2 - set2 = " << strSet2 - strSet2 << endl; cout << "Set2 - Set3 = " << strSet2 - strSet3 << endl; cout << "Set3 - Set2 = " << strSet3 - strSet2 << endl; cout << "enough testing! Program Terminating" << endl; }