Question: You have been provided a header 2 DMotion.h , which you may change as you like. However, you must implement all the functionality used by

You have been provided a header 2DMotion.h, which you may change as you like. However,
you must implement all the functionality used by the provided test harness file a3q2.cc, as
that file (or a similar one in how it uses the Point and Force classes) will be used to test
your program. You may not change the test harness, as we will test you with our own copy
of it, so any changes you make wont be reflected in how your solution is tested! You must
implement the following functions for this question:
Point default constructor. Should initialize both x and y to 0.
Force default constructor. Should initialize both angle and magnitude to 0.
An overloaded input operator for Point objects. Should read in first the x field, then
the y field.
An overloaded input operator for Force objects. Should read in first the angle, then
the magnitude.
An overloaded output operator for Point objects. Should print them out in the format:
(,)(Note is used to denote that the variables value should go
there, so if the point has x value 4, and y value 5, you should print out (4,5).
An overloaded output operator for Force objects. Should print them out in the format:
degrees with magnitude of
An overloaded addition operator between a Point object and a Force object. This
should effectively create a new Point that is the result of moving the original by that
Force. This requires a bit of trigonometry! You will require the header, and
should use the PI constant defined in the provided 2DMotion.h file. In order move a
Point by a given Force you must determine the horizontal and vertical components
of the given Force. Doing so is simple trigonometry. Consider that the magnitude of
a Force is simply the hypotenuse of a right-angle triangle. Given the hypotenuse and
angle of a right-angle triangle you can easily find out the length of the other sides (the
horizontal and vertical components) using sin and cos provided in the library
- but be wary, those operations work on radians!
An overloaded multiplication operator between a Force and an int scalar. This should
simply produce a new Force which has a magnitude scaled by the given scalar.
int Point::quadrant()- A member function that returns the quadrant (1,2,3, or 4)
that the given point is in. See quadrants in diagram above.
A test harness is provided in the file a3q2.cc. Make sure to read and understand this
code, as you will need to know what it does in order to structure your test suite.
The test harness has commnets describing the commands

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!