During lecture, we have been creating a class Complex. Refer to this class and the discussion from lecture to complete this lab.
You may turn in the assignment to your TA during lab or place it in his mailbox in 905 SEO. It is suggested that you place it in his mailbox just in case you are unable to attend lab. You are to hand in a print out of your program to do the following to your TA.
This method is to take one integer parameter and store its value into the data member for the X coordinate. This method is not to return any value.
This method is to take one integer parameter and store its value into the data member for the Y coordinate. This method is not to return any value.
This method is to take two integer parameters and store the first parameter value into the data member for the X coordinate and store the second parameter value into the data member for the Y coordinate. This method is not to return any value.
This method is to have no parameters and it to return the value of the data member for the X coordinate.
This method is to have no parameters and it to return the value of the data member for the Y coordinate.
This method is to have no parameters and it is not to return any value. This method is to print to cout the values for the X and Y coordinate within parenthesis and separated by a comma. This means in the form of:
(X,Y)
This method is to have no parameters and is to return an integer value. If the point has X coordinate greater than zero and Y coordinate greater than zero, the point is in quadrant 1 and the method is to return the value of 1. If the point has X coordinate less than zero and Y coordinate greater than zero, the point is in quadrant 2 and the method is to return the value of 2. If the point has X coordinate less than zero and Y coordinate less than zero, the point is in quadrant 3 and the method is to return the value of 3. If the point has X coordinate greater than zero and Y coordinate less than zero, the point is in quadrant 4 and the method is to return the value of 4. If the point has X coordinate equal to zero or Y coordinate equal to zero, the point is not in any quadrant and the method is to return the value of 0.
This method is to take one parameter of type Point and to return a floating point number. The return value is to be the distance from the point specified in the instance of the class the method is called with and the point specified by the parameter. The formula for this is given as follows. The formula assumes the X and Y coordinates for the two points are specified by x1, y1, x2 and y2, where the two points are (x1,y1) and (x2,y2).
distance = SQRT( (x1-x2)2 + (y1-y2)2 )
#include <iostream> // put your Point class here int main() { Point pt1, pt2, pt3, origin; pt1.setX(5); pt1.setY(7); cout << "Point pt1 is: (" << pt1.getX() << "," pt1.getY() << ")" << endl; cout << "Point pt1 is in quadrant " << pt1.getQuadrant() << endl; pt2.setXY (-2, -4); pt3.setXY (-8, 9); origin.setXY (0, 0); cout << "Point pt2 is: "; pt2.printPoint(); cout << endl; cout << "Point pt2 is in quadrant " << pt2.getQuadrant() << endl; cout << "Point pt3 is: "; pt3.printPoint(); cout << endl; cout << "Point pt3 is in quadrant " << pt3.getQuadrant() << endl; cout << "Point origin is: "; origin.printPoint(); cout << endl; cout << "Point origin is in quadrant " << origin.getQuadrant() << endl; cout << "The distance between pt1 and pt2 is " << pt1.distanceFrom (pt2) << endl; cout << "The distance between pt2 and pt1 is " << pt2.distanceFrom (pt1) << endl; cout << "The distance between pt3 and the origin is " << pt3.distanceFrom (origin) << endl; cout << "The distance between the origin and pt3 is " << origin.distanceFrom (pt3) << endl; }
Hand in a print out of your program to your TA.