CS 102 Lab #10

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!

Note: The function you implement should be fairly short: one or two lines of C++. This is less a programming lab and more a problem-solving one. If you are not that great at these sorts of math problems, you should work out (at least) on paper an algorithm that will correctly perform the mapping before you arrive at your lab time.

Remember: You will be graded on what you submit before your lab session is over.