In this exercise you will finish a program have a Point class that represents a point in 2-dimensional Euclidean space, supporting the operations listed below.
You should assume class Point is defined as follows:
class Point {
public:
// operation 1. a constructor with given x and y coordinates
Point(double xpos, double ypos);
// operation 2. get a string representation
string to_string();
// operation 3. check if two points have the same location
bool equal_to(Point other);
// operation 4. transform the point by swapping its coordinates
void reflect();
private:
double x;
double y;
};
And the main function you should follow in this Exam:
int main(){
double ax,ay,bx,by;
cin>>ax>>ay>>bx>>by;
Point A(ax,ay);
Point B(bx,by);
cout<<A.to_string()<<endl;
if (A.equal_to(B)) cout<<"A equal B"<<endl;
else cout<<"A not equal B"<<endl;
A.reflect();
cout<<A.to_string()<<endl;
return 0;
}
Example input 1:
12 10 5 7
Example output 1:
(12, 10)
A not equal B
(10, 12)
Example input 2:
11 15 11 15
Example output 2:
(11, 15)
A equal B
(15, 11)