Build and execute the program. You should not get any errors. The program declares a pair of Point objects. A Point object represents a point on the real plane, so it has two fields (data members), one for the x-coordinate and one for the y-coordinate.
Point a's xcoord is _______ and ycoord is _________ (hint: examine the constructor in Point.h)
Prove your assumption by adding a statement to main that will print Point a before its coordinates are set. Leave this line in the program as it will be graded.
Point b is created with specified coordinates using a different constructor. The output should verify this. Both Points are declared in the main program block.
______ (1, 2, or 3) When are the Points actually created?
Examine the distance method found in the Point class. This uses the standard distance formula to determine the distance between two Points. Notice that the only argument is a Point object, passed by value. In general, it is bad practice to pass objects by value (unless you need to make a copy for some reason). Change the method to receive its argument by constant reference (we want to enforce the principle of least privilege). Document the change by adding a comment just above the function with the date and your initials.
Test the program to be sure you have not changed the behavior.
Is it possible to set only one of the coordinates of a Point object in main? Try it! Uncomment the last few lines of Task 1 code and compile.
There error message tells why you cannot directly set the xcoord member of a Point object. Explain it in your own words:
_________________________________________________________________________Devise a way to accomplish the goal of changing the x-coordinate only of Point b (by adding code to main only). Replace the incorrect line in main with your solution. You can do this in a single statement (although some may prefer using a sequence of 2-3 statements). Remember: your solution is to change only the x-coordinate of Point b to the number entered by the user. Document your solution with a comment that includes your initials and what you have done.
Defined in _________________________________ with value ___________
The ___________________ constructor from the class ___________________________
Why is it necessary for this constructor to be called this many times?
_________________________________________________________________________
_________________________________________________________________________
Notice that the object d is a PathN object representing a path (sequence) of Points in the plane. It appears that two of the Points are then set to coordinates (1.0, 2.0) and (3.0, 4.0), yet when the path is displayed, this data does not appear.
Look at the member function definition for setPoint in pathN.cpp. It is incomplete. Complete it to match the specifications of the comments that are located above the method implementation (be sure to use a constant identifier rather than a "magic number" in your solution) and then run the program again. The output problem should be corrected. Record the output when the Path d is displayed:_________________________________________________________________________
_________________________________________________________________________
Change PATHLEN to 5 (in pathN.h), recompile and run. No errors should occur. Record the last line of output.
_________________________________________________________________________
Change PATHLEN to 2, recompile and run. Record the line of output that begine "Path d:"
_________________________________________________________________________
Explain what happened to the (3.0, 4.0) Point that was supposedly set in the Path..
_________________________________________________________________________
_________________________________________________________________________