Mr. Lupoli
Hit the space bar for next page
February 5th, 2010. As one of the biggest snow storms in recorded history is wreaking havoc on UMBC and
close neighbor BWI airport, Mr. Lupoli is sitting on a plane that is in line to take off for very sunny Orlando, FL.
Mr. Lupoli nervously looks out the window and see's the runway configuration below:
(runwaysBEFOREshutdown)
With Mr. Lupoli's luck, they shut down all of the runways but one. BWI's snowplow crews focus all of their energy on an
unused, ancient, WWII era runway named Runway 4. Because of this, every plane must turn around to reach Runway 4. To
make things worse, the administration at BWI wants as few people returning to the airport as possible in case of a total
closure. They clear only one plane at the head of all runways that has the
MOST passengers to take off.
(divertingToRunway4)
In this scenario, the takeoff order would be:
Plane #1
Plane #2
Plane #3
Plane #4
(rest in text)
Plane #5 SW3 with 87 passengers
Plane #6 JB2 with 98 passengers
Plane #7 SW2 with 75 passengers
Plane #8 D3 with 185 passengers
Plane #9 SW1 with 37 passengers
Plane #10 D1 with 230 passengers
Plane #11 AA1 with 123 passengers
Plane #12 AA3 with 108 passengers
Given three files that will represent the three Runways (1, 2, and 3), your task is to write a program that will:
The files will resemble below:
runway1.txt | runway2.txt | runway3.txt |
AA3 108 SW1 37 JB1 95 D2 287 |
AA1 123 D3 185 JB2 98 AA2 154 |
D1 230 SW2 75 SW3 87 SW4 86 |
You will also be given a file "Airplane.py" that is the object file for our
"planes". You are not to edit this file, but you will need to use it.
You are required to (in this order):
1. Print a greeting.
2. Read the data (planes) from a file and place into 3 separate stacks named runway1, runway2, and runway3.
3. The 3 Stacks and 1 Queue used in this program MUST ONLY contain INSTANCES of Airplanes. (Not just Strings, Numbers, etc...) Use the Airplane.py file given to accomplish this.
4. Create an algorithm that will pull the most populated plane from the three stacks, and place it into a queue, until all are empty.
5. Print ONLY the Flight Name and Passenger Count to both the screen and file (results.txt).
6. Print the average wait time per passenger within 2 decimal places to both the screen and file (results.txt).
You must use both a stack and a queue to solve this problem. To divide up the effort of this problem, consider the program as consisting of two phases:
The data file used to create the sample output for this project is called runway1.txt, runway2.txt and runway3.txt. You may get a copy of this file from my pub directory.
Here's the sample data files:
runway1.txt
runway2.txt
runway3.txt
This is the Airplane object file that will be required for your project. Look over it carefully. All items in the simple file are covered in class.
Using the same data shown above, here is my sample run:
Welcome to the BWI Snowmagedon Simulator!! The files runway1.txt, runway2.txt and runway3.txt will now be read. Here are the results (which can be found in results.txt) JB1 95 SW4 86 AA2 154 D2 287 SW3 87 JB2 98 SW2 75 D3 185 SW1 37 D1 230 AA1 123 AA3 108 Average wait time of 32.55 minutes per person
Upon close inspection of the file, every instance of Airplane will contain a flightName and number of passengers. Below is SOME code showing how to access some of the object's features. But this type of code will reside in your proj1.py .
from Airplane import * def main(): testPlane1 = Airplane("SW1", 37) print testPlane1.display() #displays the entire instance of testPlane1 #using mutators testPlane1.setFlightName("AA 21") #changed testPlane1's flightname testPlane1.setNumOfPassengers(135) #changed testPlane1's number of passengers #using accessor ... can't tell you everything!!!
You must be logged into your account and in the same directory as the file you are trying to submit.
To submit your design, type the following at the linux prompt:
submit cs201 Proj1 design1.txt
To submit your project, type the following at the linux prompt:
submit cs201 Proj1 proj1.py queue.py stack.py
To verify that your file was submitted, you can execute the following command at the Unix prompt. It will show all files that you submitted in a format similar to the Unix 'ls' command.
submitls cs201 Proj1