// driver for p6_06.cpp #include #include #include #include "Complex.h" using namespace std; // This program takes a maximum size digit to generate and a // number of trials to run. For each trial, it generates two Complex #s // and then runs all of the operations on them. Checking of the // results is currently not done, so you'll have to eyeball them // or write them yourself. // Note this code doesn't test the overloading of operators // == and !=. You should be able to add this yourself. int main(int argc, char* argv[]) { srand(time(0)); if (argc < 2) { cerr << "Usage: " << argv[0] << " max_int num_trials "; exit(1); } int max_digits = atoi(argv[1]); int num_trials = atoi(argv[2]); for (int i = 0; i < num_trials; i++) { int xr = rand() % max_digits; int xi = rand() % max_digits; int yr = rand() % max_digits; int yi = rand() % max_digits; Complex x(xr, xi); Complex y(yr, yi); x.printComplex(); cout << " + "; y.printComplex(); cout << " = "; x.addition( y ); x.printComplex(); cout << endl; x = Complex(xr, xi); y = Complex(yr, yi); x.printComplex(); cout << " - "; y.printComplex(); cout << " = "; x.subtraction( y ); x.printComplex(); cout << endl; } Complex d; cout << "Input a complex number: "; cin >> d; cout << d << endl; Complex b(rand() % max_digits, rand() % max_digits); cout << b << endl; cout << b * d << endl; return 0; }