Reference no: EM132223475
Lab : Point Class
This assignment will provide practice with object-oriented design and coding (classes, objects, constructors, operator overloading, friend functions). The task is to implement a Point class to represent points in a two-dimensional Cartesian coordinate system. To help you understand the required functionality that the class must implement, a driver program is available that demonstrates the usage of objects of Point class by a client. One of the main tasks is to overload several operators that can be used by the client. They are defined as such:
Operator
|
Functionality |
Description
|
%
|
Rotation
|
Member function that rotates a Point about the origin by the specified number of degrees. Returns a new Point.
|
_
|
Distance (Binary operator)
|
Member function that calculates the difference between two Points and returns the distance (type double).
|
^
|
Midpoint
|
Member function that calculates the midpoint between two Points. Returns a new Point.
|
+=
|
Translation
|
Add two Points or a Point and a double and returns a reference to the left-hand operand which has been modified. These are both member functions.
|
-
|
Translation
|
Member function that subtracts a double from a Point and returns a new Point.
|
++
|
Pre/Post Increment
|
Add one to the x/y values of the object. There are two versions, one for preand one for post-increment. Pre-increment returns a reference to the incremented Point and post-decrement returns a new Point with the value of the "before incremented point". Both are member functions.
|
--
|
Pre/Post Decrement
|
Subtracts one from the x/y values of the object. There are two versions, one for pre- and one for post-decrement. Pre-decrement returns a reference to the decremented Point and post-decrement returns a new Point with the value of the "before decrement point". Both are mmber functions
|
-
|
Unary Negation
|
Member function that returns a new Point with the x/y values of input Point negated.
|
+
|
Translation
|
Adds two Points or a Point and a double and returns a new Point. The Point/Point method is a member function. However, there are two versions of the double/Point function. One is a member function while the other is nonmember non-friend function.
|
*
|
Scale
|
Multiplies a Point by some numeric factor of type double and returns a new Point. There will be two versions of this ± one is a member function while the other is a non-member non- friend function.
|
<<
|
Output
|
Outputs a Point in the form of a string: (x, y), where x and y are the coordinates, e.g. (4, 7). This is a friend function. Make sure you format it exactly as shown.
|
>>
|
Input
|
Inputs a Point. Allows two numbers (separated by whitespace) to be entered, e.g. 4 7. This is a friend function. The inputs are both of type double.
|
The following syntax will be supported:
Point pt1(3, 4); // pt1 is (3, 4)
Point pt2; // pt2 is (0, 0)
Point pt3(pt1); // pt3 is (3, 4) - uses the default copy constructor
Point pt4 = pt1; // pt4 is (3, 4) - uses the default copy constructor
Point pt5; // pt5 is (0, 0)
pt5 = pt4; // pt5 is (3, 4) - uses the default assignment operator
The following syntax is not allowed:
Point pt6 = 4; // this should not compile
Point pt7(4); // this should not compile
The starting point for the interface is in Point. h which is provided. You will need to modify this before implementing the functionality in Point . cpp. You will not need to use the new keyword in this assignment as wedo not require any dynamic memory allocation. If you are not sure of the functionality of an operator, look at the sample driver and output. All of the information you need can be discovered from the sample test program (driver-sample.cpp) that is provided.
What to Submit
You must upload your header file (Point.h), implementation file (Point.cpp), Doxygen-generated index.chm, and the signed programming assignment checklist in a .zip file to the assignment web page. Note that you are not submitting any other file. Hard copy submissions will not be accepted.
Description
Point.cpp - The implementation file. All function definitions go here. You must document the file with a file header comment. You do not have to use fully formatted function header comments for the overloaded operator functions, but you still must put a comment above the function saying what it's purpose is (e.g. adding a double and a Point). You also don't have to document the very trivial functions but you still must document code that is non-obvious. In other words, if you have more than a couple lines of code, you must document it.
Point.h - The header file. You will need to modify the one I posted. You must document the file with a file header comment. Absolutely NO implementation permitted in this file.
Usual stuff
Your code must compile (using the specified compilers) to receive credit. Make sure your name and other information is on all documents (paper and electronic).
Attachment:- Lab.zip