//////////////////////////////////////////////////////////
//
// cmplxtst.cpp - Test of complex number class
//
//////////////////////////////////////////////////////////

#include <iostream.h>
#include "complex.h"

main() {

	cout << "Test of complex numbers." << endl << endl;

	cout << "Constructor calls:" << endl;
	cout << "   Complex()    = " << Complex() << endl;
	cout << "   Complex(1)   = " << Complex(1) << endl;
	cout << "   Complex(1,2) = " << Complex(1,2) << endl << endl;

	Complex a(1.0,2.0);					//floats.
	Complex b(3,4);						//ints.
	Complex c(5);

	cout << "   a = " << a << endl;
	cout << "   b = " << b << endl;
	cout << "   c = " << c << endl;

	Complex d = a;							//force copy constructor call.

	cout << endl << "Test copy c'tor by making d a copy of a:" << endl;
	cout << "   d = " << d << endl << endl;

	cout << "Simple arithmetic operations:" << endl;
	cout << "   a + b = " << a + b << endl;
	cout << "   a - b = " << a - b << endl;
	cout << "   a * b = " << a * b << endl;
	cout << "   a / b = " << a / b << endl << endl;

	cout << "Using automatic type conversion:" << endl;
	cout << "   d + 1 = " << d + 1 << endl;
	cout << "   (a + b) / (c + 1) = " << (a + b) / (c + 1) << endl << endl;

	cout << "Using the add() and sub() member functions:" << endl;
	a.add(b); cout << "   a + b = " << a << endl;
	a.sub(b); cout << "   a + b - b = " << a << endl;
	a.sub(b); cout << "   a + b - b - b = " << a << endl << endl;

	cout << "A complex number identity result:" << endl
		  << "   (a+b)*(a-b) / ((a-b)*(a+b)) = "
		  <<     (a+b)*(a-b) / ((a-b)*(a+b)) << endl << endl;

	cout << "And another:" << endl
		  << "   (a+b)*(a-b) / ((b-a)*(b+a)) = "
		  <<     (a+b)*(a-b) / ((b-a)*(b+a)) << endl;

	return 0;
}
