Question: Create a program in C++ following the guidelines below: 1. (50 points) Define a class point and use this class in your main function. You
Create a program in C++ following the guidelines below:

1. (50 points) Define a class point and use this class in your main function. You are expected to meet the following criteria: 1) The class has two private members, double x and double y, to represent the point's x and y coordinates (4 points). 2) The class has two constant public member functions, get_x0 and get_y0, that allow us to retrieve the current x and y of a point (5 point). 3) The class has a modification public member function, shift(double x amount, double y_amount), that allow us to shift a point by given amounts along the x and y axes (5 point) 4) The class has a modification public member function, rotate900, that allows us to rotate a point by 90 in a counterclockwise direction around the origin axes (6 point). (Hint: For a 90-degree counterclockwise rotation, the new x is the original -y, and the new y is the original x) 5) The class has a constructor function point(double initial_x, double initial_y) that allow us to initialize the coordinate of a point (6 point); The constructor also has two default arguments: initial_x0, initial_y 0 (2 point). 6) In your main function, i) create an object of your point class (1 points); ii) shift the coordinate of your point by (a, b) via function shift (1 points); ii) rotate the point once via function rotate90 (1 points); and iv) print out (e.g., using cout) the point's current coordinate in format: "The current coordinate is (x, y)." (2 points) 7) Define an overloading binary arithmetic operator for your class: if we have two objects pl and p2 with coordinates (xl, y2) and (x2, y2), respectively, then pl - p2 will return a point object with coordinate (xl-x2, yl- y2) (5 point). (Hint: you can refer the example of overloading operator + in page 76-77 in our textbook) 8) Define a function rotations_needed of which the argument (input) is a point object, say p, and the return value (output) is the number of 90-degree counterclockwise rotations needed to move p into the upper-left quadrant (when x 0). After calling this function, the coordinate of your object p won't be changed (5 point). 9) Define a function rotate_to_upper_left that can rotate a point object to the upper-left quadrant. Note that the coordinate of original p will be changed after calling this function (5 point) 10) Please don't forget to write a postcondition for each of your function. If a function has any argument, you also need to have a precondition before defining this function (2 point)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
