Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

AIR PORT SIMULATION(HELP REQUIRED in c++)

Status
Not open for further replies.

allurz

Newbie level 5
Newbie level 5
Joined
Feb 27, 2006
Messages
9
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,283
Location
Abu Dhabi
Activity points
1,460
c++ airport program

Overview
Your job will be to simulate the arrivals and departures at an airport in a time sequence of up to a single 24-hour period. The airport has N runways. The simulation works in time units of one minute. During any one minute, planes may enter the system, they may land, they may take off, or they may crash. Your program must keep track of planes, assign planes to runways, execute the take-offs and landings and keep track of the status of each plane.
Program Command-Line
The command-line for the program will be
C:>airport N planes output
where N is an integer giving the number of runways at the airport, planes is a text file containing the main input to the simulation, and output is your text output file.
Warning! I will check only programs that implement command-line, and filing, consult C++ books/help for this.
Runways
The runways should be numbered 0 .. N-1. Each should have two queues associated with it, one for planes waiting to take-off and one for planes waiting to land. Each runway may be used by at most one plane in each minute. In other words, each runway may be used for a take-off during a time unit, for a landing during a time unit, but not for both. Exceptions are emergency landings and crash landings. These are explained below.
Input File
The first line of input in planes contains the starting time, which is specified as two integers giving the initial hour and minute. Each subsequent line specifies
a) an increment of time,
b) a request for a plane to enter the take-off queue,
c) a request for a plane to enter the landing queue, or
d) a request for the status of a plane.
These are described as follows:
• When an input line contains the ’+’ sign as the first (and it will be the only) non-whitespace character, increment time by one minute and do operations described below to handle start of the next minute.
• A request to enter a take-off queue is specified by a line such as the following
T SW 1297 13 10 231
The T (always a capital letter) indicates that this is a take-off. The combination of the string SW and the integer 1297 specifies the airline and flight number. The numbers 13 and 10 indicate that the flight was supposed to leave at 13:10 (or 1:10 pm). Each plane requesting take-off should be immediately placed into a runway queue, even if the time is before the specified departure time. Finally, the number 231 indicates the number of passengers on the plane.
• Information about a landing plane is specified by
L SW 1297 13 10 15 18 231
Here, the L (always a capital letter) indicates that this is a landing. The combination SW and 1297 specify the airline and flight number. The numbers 13 and 10 indicate the time this plane was originally scheduled to arrive. The number 15 indicates the number of minutes until this plane will be at the airport and ready to land. In other words, the plane is “in range”. In this case, the plane can not be assigned to a landing queue until 15 minutes later. The number 18 indicates the number of time units of fuel the plane has left. You may assume that this number is at least as large as the number of time units until the plane reaches the airport, and you may assume both numbers are positive. Finally the 231 indicates the number of passengers.
• A status check request is specified by a line such as
S SW 1297
The input format will be correct.
Note that landing planes become known to the program while they are still some number of minutes away from the airport. They can not be assigned to a runway until they reach the airport. Take-off planes are immediately assigned to a runway when they read by the program.
The handling of input ends with the end of the input file. Subsequently, the program should increment time minute-by-minute, using the runways as described below, until the runway queues are all empty.
What To Do During Each Minute
At the start of each minute (after a ’+’ is read), before reading any more input, your program must
a) decrement the number of minutes of fuel remaining for all landing planes,
b) decrement the number of minutes until plane reaches airport when a landing plane hasn’t yet reached airport, and
c) for planes waiting in a take-off or landing queue, increment the number of minutes the plane has waited. Then check for landing planes that have just reached the airport (minutes until arrival has just reached 0). Assign each of these to a runway, choosing the runway with the fewest planes waiting to use it in each case. Break ties by choosing the runway with the lower number (e.g. runway 1 before runway 2).
Once all of this is done, the program should print the contents of the queues (doing this will help you debug). The format of this output should be something like: At start of time 12:56
Runway 0
Take-off queue:
SW 1876 in queue for 1 minutes.
AE 4379 in queue for 1 minutes.
Landing queue:
<empty>
Runway 1
Take-off queue:
Amer 179 in queue for 1 minutes.
Landing queue:
USAir 977 in queue for 1 minutes. 1 minutes of fuel remain.
Next (still at the start of the time unit), the program must do the following, in order:
1. Start by looking for planes that must crash. Any landing planes that have a negative number of units of fuel remaining will crash in this time unit (minute). Multiple planes may crash in any given minute. Whenever there is a crash, it takes 5 minutes to clean up the mess and issue travel vouchers to all passengers on the plane (remember, all survive), so no runways can be used during this time. The time at which a plane crashes counts as 1 of the 5 minutes. For each crash, the output should be of the form
SW 1297 with 231 passengers crashed at 13:25.
Expected arrival time was 13:01.
Note that in 5 minutes after a plane crashes, more planes might crash, extending the time until the runways are usable.
2. If no planes crash in this time unit and if there hasn’t been a crash in the past 5 minutes, then look for emergency landings. An emergency landing is required when a plane has 0 units of fuel remaining. In this case, the plane must land on its assigned runway, and because it is an emergency, all runways are cleared and no other runway may be used during this minute. If there are multiple emergency landings only the first one can be accommodated. The meaning of “first”, in this case, is the emergency plane on the lowest numbered runway. When there is more than one such plane requiring an emergency landing, the one closest to the front of the queue is chosen. For each emergency landing the output should be of the form
SW 1297 with 231 passengers made emergency landing on runway 2 at 13:23.
Expected arrival time was 13:01.
3. If there have been no crashes in the past 5 minutes and there are no emergency landings in this minute, then handle normal take-offs and landings. In choosing between take-offs and landings, simply choose the plane that has been in the queue the longest. Break ties by choosing the plane waiting to land.
Whenever a plane actually uses a runway a message is output to the output file. For planes that are landing, the output should be of the form
SW 1297 with 231 passengers landed on runway 0 at 13:17.
Expected arrival time was 13:01.
For planes that take off, the output should be of the form
SW 1297 took off on runway 0 at 13:17.
Expected departure time was 13:01.
The last thing to do in each time unit is to handle the input. (Note that the order of processing means that each plane will stay in the runway queue at least one minute.) For each plane wanting to take-off, choose a runway. As above, pick the runway with the fewest number of planes waiting to use it, and break ties by picking the lowest runway number. For each plane coming in range, add the plane to a list of planes that are in range but not yet at the airport (and therefore not yet in a landing queue). Before doing either of these, however, first check to see if the plane is already in the system (same airline and flight number). Output an error message and ignore this line of input if it is. The message should be simply
Error: SW 1297 is already in the system.
For plane status requests, the program should first check to see if the flight has been entered yet. If not, it should output
Error: SW 1297 is not in the system.
and continue to the next request. Otherwise, the output will depend on the current status of the plane. Here are examples showing all status possibilities
Status: SW 1297 is in range and will land at 13:23 or later.
Status: SW 1297 is queued to land on runway 1, 12 mins of fuel remaining
Status: SW 1297 is queued to takeoff on runway 0.
Status: SW 1297 with 231 passengers took off at 13:23.
Status: SW 1297 with 231 passengers landed at 13:23.
Status: SW 1297 with 231 passengers made an emergency landing at 13:23.
Status: SW 1297 with 231 passengers crash landed at 13:25.
Output
The foregoing describes the total output from the system. (There should be a blank line after printing the runway queues.) Example input and output will be posted soon on the course web site.
Additional Requirements and Suggestions
• It is crucial that you start this assignment by designing your classes. You will need (at least) classes to represent a Take-Off plane, a Landing plane, and a runway.
• Hint: internally, just keep all times as minutes, instead of hours and minutes. Thus, for example 13:01 would be 781. Only worry about hours and minutes when you write the output.
• enum types may help you with this assignment. Look them up in your textbook(s) if you don’t know how to use.
• Don’t use a queue because of the necessity of removing planes from the middle. Instead use a list.
• A key decision you will need to make is how to keep track of the planes. Certainly, when your program receives a status request, it shouldn’t have to look through all of the queues to find a plane. Moreover, your program needs to keep track of planes in various stages: in-range, but not yet landed, in a landing queue, in a take-off queue, etc. You need to be careful to avoid having two different objects representing the same plane. One way to do this is to just keep the airline and flight numbers in the various lists and queues, while keeping the actual planes in a separate structure (or structures). A second way to do this is to keep pointers to (dynamically allocated) plane objects in the various lists and queues. There will be only one plane object for each plane, but there could perhaps be multiple pointers to it. The danger with using multiple pointers to one object is that it is not clear who “owns” the object (and therefore has the right to delete it). This is not a particular problem here.
If you decide to use pointers, then you will need to be a bit careful with the syntax. E.g., if you have a std::list<TakeoffPlane*> queue; as the queue of planes on a runway waiting to take-off and if the TakeoffPlane class has a member function increment minute to add a minute to the waiting time, then the code
for ( std::list<TakeoffPlane*>::iterator p = queue.begin(); p != queue.end(); ++p )
{ (*p)->increment_minute(); }
will do the operation for each waiting take-off plane. The *p accesses the contents of the list entry (which is a pointer) and the -> follows the pointer to the object and applies the member function.
• Finally, if you pass a stream object (input stream or output stream) to a function, must pass it by reference!


can any one help in this regard.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top