/**************************************************************************** * * * File: PointTest.cpp * * * * Author: Robb T. Koether * * * * Date: Oct 19, 1999 * * * * Purpose: This program will test the member functions and operators * * of the Point class * * * ****************************************************************************/ // Header files #include #include #include "Point.h" using namespace std; /**************************************************************************** * * * Function: main * * * ****************************************************************************/ int main() { // Test the constructors and the output operator cout << "Test the constructors and the output operator" << endl; Point P; // Test the default constructor Point Q(2, 3); // Test the other constructor Point R = Q; // Test the copy constructor cout << "P = " << P << endl; // Test the output operator cout << "Q = " << Q << endl; cout << "R = " << R << endl; // Test the assignment operator cout << endl << "Test the assignment operator" << endl; cout << "Assign Q to P" << endl; P = Q; // Test the assignment operator cout << "P = " << P << endl; // Test the inspectors cout << endl << "Test the inspectors" << endl; cout << "The x-coordinate of Q is " << Q.getX() << endl; // Test GetX() cout << "The y-coordinate of Q is " << Q.getY() << endl; // Test GetY() // Test the mutators cout << endl << "Test the mutators" << endl; cout << "Enter the x-coordinate of P: "; double x; cin >> x; P.setX(x); // Test SetX() cout << "Enter the y-coordinate of P: "; double y; cin >> y; P.setY(y); // Test SetY() cout << "P = " << P << endl; // Test the input operator cout << endl << "Test the input operator" << endl; cout << "Enter a point (x, y): "; cin >> R; // Test the input operator cout << "R = " << R << endl; // Test the equality operators // Use equal points cout << endl << "Test the equality operators" << endl; if (P == P) // Test equality of equals cout << "P == P" << endl; else cout << "P != P" << endl; if (P != P) // Test inequality of equals cout << "P != P" << endl; else cout << "P == P" << endl; // Use unequal points if (P == Q) // Test equality of unequals cout << "P == Q" << endl; else cout << "P != Q" << endl; if (P != Q) // Test inequality of unequals cout << "P != Q" << endl; else cout << "P == Q" << endl; // Test the add and multiply functions cout << endl << "Test the addition and multiplication operators" << endl; cout << "P + Q = " << P + Q << endl; // Test addition of points // cout << "P - Q = " << P - Q << endl; // Test subtraction of points cout << "5 * P = " << 5 * P << endl; // Test scalar multiplication // cout << "P / 5 = " << P / 5 << endl; // Test scalar division // Test the distance function cout << endl << "Test the distance function" << endl; cout << "The distance from P to Q is " << P.distance(Q) << endl; // Test the distance function cout << endl << "Good-bye" << endl; system("pause"); return 0; }