Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

design and implement a class called point ( cpp file is at the bottom) Requirements for point: 1a) a .h header file and .cpp implementation

design and implement a class called point ( cpp file is at the bottom)

Requirements for point:

1a) a .h header file and .cpp implementation file named Point with Pre and Post Conditions for each member function clearly written in the .h file.

1b) All member functions that should not change the calling object should be const. All parameters that do not get changed should be const. All Point objects passed in should be const reference (i.e. const Point& pointPassedIn)

1c) The point object must have the appropriate state variables. Look at the above figure to determine how many state variables it takes to accurately represent a point and the appropriate data type.

2) A Constructor with default values that either initializes each point to what is passed in, or, if a value is not passed in, intializes the value to 0. This should work as follows

Point firstPoint;//firstPoints (x,y)=(0,0)

Point firstPoint(2.3);//firstPoints (x,y)=(2.3, 0)

Point firstPoint(2.3,-3.2) //firstPoints (x,y)=(2.3, -3.2)

3) An explicitly defined Copy constructor which initializes a point object to be a copy of an existing point object. DEFINE THIS EXPLICITLY (even though you technically do not have to in C++).

5) Getters for the x and y coordinates of a point. These must be named get_x() and get_y() and return a value of the appropriate data type

6) Setters for the x and y coordinates of a point. These must be named set_x(____) and set_y(____) and take in the appropriate parameter value

7) Translation: translate(___,___), Translating a point is equivalent to adding a fixed pair of numbers (x,y) to the cartesian coordinates of the point. So if I translate my point, lets call it pointA at (x,y), by (X,Y) pointA will now be located at coordinates (x+X, y+Y)

8) Scaling: scale(___): Scaling a point is equivalent to multiplying both coordinates of a point by some constant. So if I have pointA at (x,y) and I scale it by m, pointA will now be located at coordinates (m*x,m*y)

9) Reflection: reflect_x(): This reflects the point over the x-axis. If I have pointA at (x,y), after reflecting over the x-axis pointA will now be located at coordinates (x,-y).

reflect_y(): will reflect the point over the y-axis. If I have pointA at (x,y) after reflecting over the y-axis pointA will now be located at coordinates (-x,y)

10) Rotation: Must include cmath for this.

11) Overload the assignment operator (=). This must be explicitly defined (even though C++ gives you a default operator =s if you do not define one).

12) Overload the comparison operator (==). This must be overloaded as a NON-MEMBER. Two points are deemed the same if they are at the same coordinates. Note you do not const a non-member.

13) Overload cin as a FRIEND function. if I have pointA and say cin>>pointA and user types in 12.4 and 13.2 either separated by a space or enter, pointA should now be at the coordinate (12.4,13.2).

14) Overload cout as a FRIEND function. if I have pointA at coordinate (12.4,13.2) and say cout<

output should look like

MUST IMPLEMENT GETTERS BEFORE TESTING What would you like to test? 1-value constructor 2-copy constructor 3-setters test 4-translation test 5-scaling test 6-reflect over x-axis test 7-reflect over y-axis test 8-rotation 9-assignment operator 10-operator equals equals 11-cin overload 12-cout overload **Value Constructor Test: Value Constructor Works 

https://drive.google.com/file/d/18aRTBCkehClWJIPyne-DuDrg5NxwYhAV/view

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

2. Define communication.

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago