Congratulations! After a successful demo of your ATC prototype, you have been awarded the contract to develop the system. Luckily for you, the previous contractor was killed in a plane crash right after completing the graphical front end for the system. All you have to do is extend your plane class to plug in to the existing software.
The interface for the Plane class has already been developed and approved by the ATC Union (your customer). Although the private section of the class is completely up to you, the public section must be as shown in ~cs102/ATC/planes-public.h
Several changes are implied by this interface. First of all, you need to add a new constant indicating how close planes have to be in order to crash into each other. Note that this is different than a proximityAlarm, which we would hope would go off well before two planes crash. It is safe to assume in your implementation that the crash distance is less than the "too close" distance. You also need constants for the maximum allowed changes to the speed and direction of planes, the default speed for new planes, and anything else you think would make your code more flexible. You also need to be sure the velocity does not fall below some minimum value, and does not exceed some maximum value.
You must add a new constructor, and remove one. Remove the constructor from the previous project that took the number and initial position. Add a constructor (the second one in ~cs102/ATC/planes-public.h) that takes three paremeters: number, direction, and relativeHeight. This constructor must set the planes number and the direction, from the params. The speed should be set to a default value that is defined as a constant in your class. The initial position should be set based on the direction and the relative height as follows: if the direction is between -90 and 90, the plane is flying left to right, therefore the initial x position is the far left in your plane coordinates if the direction is between 90 and 270, the plane is flying right to left, and therefore the initial x position is the far right. Note that -90 = 270, and you must account for that. The relativeHeight is a number between 0 and 1, indicating the percentage of the maximum height the initial y position should be. i.e. if relativeHeight is .3, the initial y position should be 30% of the maximum height in your planes coordinates.
The choices for the values of all the constants are completely up to you. The point here is to emphasize that the code should work regardless what these values are - within the constraints set by common sense. Do not arbitrarily or randomly pick values for your constants, think about them a bit. Use general common sense knowledge that you have about the world: the minimum speed should be far less than the maximum, the maximum change for the speed should be far less than the maximum speed, passenger planes can not change directions by 180 degrees in one second (which is the amount of time between animation steps), etc.
To get started, copy the files from ~cs102/ATC/ into your
directory. You will create ONLY TWO FILES: planes.h
and planes.C. You can compile your planes.C file into
a ".o" file using g++ -c, but when you are ready to compile the whole
program, you should type make. The make program will compile
all the necessary files and bring in all the required graphics libraries.
Make also only recompiles files that need to be.
You should look at the window.C file, which contains the
code that calls yours, to be sure you understand how your functions
are to be used. However you should not change any of the provided files. Only
your planes.C and planes.h files will be used in the final grading.
The display method for your planes class is provided in the file planes-display.C. Copy this into your planes.C file. Note that to work properly, your transformCoordinates function must be implemented.
Note that, as the simulator program described below demonstrates, the provided code works, given a properly implemented plane class. However, if you think you've found a bug, please report it immediately so that it can be corrected. Send mail to both Chris and Brad in such an event. Keep an eye on the course web page for any announcments regarding changes, fixes, advice, etc.
WORK INCREMENTALLY. This final project extends your previous homework assignment. Do not make all the changes at once, or you will be overwhelmed. Most of these extensions, if thought about carefully, involve simple one line changes to your existing code. Make each new change, and then compile. Fix your errors before making the next change.
There is a working version of the simulator in ~cs102/ATC/.
Go to that directory and type sim. If you get an error
from ld.so.1 about some file not found, then type:
setenv LD_LIBRARY_PATH /usr/local/libYou can put this line into the file
.cshrc in your home
directory if you want it to happen automatically whenever you log in.
You only need to type this once per login session (again, unless you
put the line in your .cshrc file).
When the simulator is running, you can do three things:
sim from. This is the output of the plane output
operator.