Cover page images (keyboard)

Proj1 - Snowmageddon at BWI
(Stacks and Queues)


design1.txt due on Sunday, 4/22/12, before 11:59 PM EST
proj1.py due on Sunday, 4/29/12, before 11:59 PM EST

Mr. Lupoli

Hit the space bar for next page

What's In a Design Document ?


Background

Snowmageddon at BWI

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

The Task

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.txtrunway2.txtrunway3.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.

Program Requirements

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).

The Phases

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:

  1. The first phase takes care of reading the files and placing all data (from one line) into an instance of an airplane, then that entire instance into a stack. Again, this will happen 3 times for each runway, but use 3 different stacks.
  2. The second phase of the program takes the 3 stacks of airplanes, pulls the plane with the HIGHEST passenger count, and places the entire airplane instance into the queue. This is repeated until all 3 stacks are empty. There should be ONLY one queue.
  3. The last phase would be to empty the queue that contains all of the planes while:
    • Printing the values to the screen
    • Printing the values to the file results.txt
    • Displaying the average wait time to the screen

Data File & Sample Run

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

A word about the Airplane.py file

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!!!

Submitting your work

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