During this lab you will add a new member function to your Plane class that is required in order for your final project to work correctly. You will not be able to do this lab if you haven't completed the last assignment, as it makes use of the code you just turned in.
The final project will display the position of all planes within the ATC's control region in a graphics window. You'll be able to watch as the planes move and be alerted when two planes are too close to one another. This display window can be resized by the user, but must always display the entire ATC control region (otherwise we might not see planes that are within ATC control and would not be able to avert in-flight disasters).
For this lab you will implement a member function that maps the
actual coordinates of an airplane into coordinates in the display
window. The display window's lower-left corner is always at (0,0),
but its upper-right corner can vary as the user resizes the window.
You must write a function that is passed the coordinates of the
upper-right corner of the display window (a Coord)
and returns a Coord in the display window that corresponds
to the plane's position within the ATC control region.
For example, if a plane was located at the lower-left corner of the ATC control region, it should map to position (0,0) in the display window. If the plane was in the middle of the ATC control region, it should map to the middle of the display window, etc.
On with the details!
plane.C file is
located.
plane.C to add the following member function.
(Don't forget to add it to your .h file as well.):
Coord Plane::transformCoordinates(Coord displayUpperRight) const;
test.C to the same
directory.
test.C with plane.C and
vector.o and run the resulting executable.
The code in test.C will ask for the boundaries
of the ATC control region that you defined for your plane
class, then test out the new function you wrote. If the
function doesn't work properly, a message will be printed
describing what went wrong.
Remember: You will be graded on what you submit before your lab session is over.