CSE 143 Autumn 2000

Homework 5

Due:
Part I electronic submission by 1 pm, Wednesday, Nov 22.
Part I paper receipt due at the beginning of lecture on Wednesday Nov 22.
Part II (entire assignment) electronic submission 10 pm, Friday, Dec. 1.
Part II paper receipt due when you meet with your TA to demo your project.

You must do Part I of this assignment by yourself (it is quite short).
You may work with a partner for Part II.  If you do, you and your partner should turn in one assignment with both of your names on it.


Overview

In this assignment, you will create a simulation for an airport.

Concepts

The purpose of this assignment is to gain experience with the following new concepts:

Program Synopsis

This program simulates an airport using graphics, without any necessary interaction from the user. (Once you are done with the coding, you can just sit back and enjoy watching your simulation.) Starter code has been provided, and you will add to it to complete the assignment.

The simulation has one central object, the airport. All the other objects are contained inside this object. The airport has a set of runways. Each runway has a takeoff queue and a landing queue. The queues hold the planes waiting to takeoff and land respectively. (Depending upon the kinds of events you add to the simulation, you could end up with additional queues.) Each element of a queue is an event. For the takeoff queue, it is a takeoff event; for the landing queue, it is a landing event. Each event has an aircraft object associated with it. There is a controller that keeps the simulation going by generating a sequence of events. In generating an event, the controller has to do two things: decide which event to generate (takeoff or landing, and possibly others you design), and decide which runway to schedule the event on. In the final version of the program, the controller should make both decisions randomly.

The starter code provided for you creates a single runway and simulates the takeoff of a single plane on that runway. Once the takeoff is over, the simulation comes to a standstill. You will be enhancing this code in both parts of this assignment.

PART I:

Overview: In PART I, you should add the ability to simulate a second runway. In addition, you should modify the implementation of the queue data structure used in the code provided to you.  You should do all of the coding for this part by yourself.

What to do

  1. Read through and become familiar with all of the starter code provided. Also become familiar with the notion of simulation as realized in this program. Determine how the different classes are related to each other. Also, find out what the different member functions do.
  2. You should have become relatively familiar with GP142 by now (having used it in HW4). You don't need to acquire a great depth of knowledge about the functionality of GP142. All you need to be aware of is what all functions are provided by this package, for which you should read gp142display.h. This would be helpful in enhancing the graphics in Part II. For more information, you can read GP142 or GP143 pages.
  3. The Queue data structure. At the heart of any simulation, more often than not, there is a queue data structure. So, there should be no surprises for you when you find one in this simulation too. The queuein the starter program is very simple; it has been implemented using just the front pointer.  In this part of the assignment, you should change this data structure to use a more efficient implementation that has a front and the rear pointer.
  4. In order to add another runway, you need to read through the starter code to find how the single runway is created in the starter program. You need to add one more runway in a similar manner. However, even after adding multiple runways to the airport, you will see just one plane takeoff because currently in the starter code, only one takeoff event is being generated. (Hint: adding a new runway needs just one line of code)

Part I requirements

  1. Change the implementation of the queue data structure from the one which uses just the front pointer to the one that uses both front and the rear pointer. In particular, you should to change the functions EventQueue::enqueue and EventQueue::dequeue.
  2. Add one more runway to the airport so there are two runways.

This part is due Wednesday, Nov 22nd.

This finished solution for PART I should work like this: Part I Solution

PART II:

Overview: In Part II, you will complete the simulation. Part II is more or less open ended. There are a few minimum things that you are required to do for this part. Beyond that, use your imagination to do something interesting!!  You may work with a partner on this part of the assignment.  If you do work with a partner, the two of you should turn in a single assignment.

What to do

  1. Currently, just one takeoff event is generated in the simulation. Once that event is over, the simulation comes to a stand still. You should add the ability to generate multiple takeoffs, one after another. For this, you have to figure out how the single event in the starter code is generated, then add similar code in the main event loop at appropriate places to generate multiple takeoffs. (Hint: cut and paste skills might come in very handy here).  The simulation will look better if you randomly choose when to generate takeoff events, and which runway to use.
  2. The next thing to do after getting the multiple takeoffs working is to simulate landings. To do this, you will need to implement the class LandingEvent and the corresponding queue for events, LandingQueue. The implementation of Landing will be very similar to the implementation of TakeOff. For ideas, look at the files for Takeoff, provided in the starter code. A LandingQueue is not required to have a visible representation on the display, although you could do this if you want. However, your landing simulation should have at least all the features depicted in the sample executable, namely the plane leaves the runway via a taxiway after it has landed.
  3. Add an additional kind of aircraft to the simulation.  To do this, you need to extend abstract class Aircraft to create another class, say NewAircraft.  To do this, you will need to create files NewAircraft.h and NewAircraft.cpp.  Once you have an additional aircraft defined, add it to the simulation so that both kinds of aircraft can appear in different events.

Part II requirements

  1. REPEATED TAKEOFFS: Add the ability to generate repeated takeoffs
  2. LANDING: Add aircraft landings to the scene by implementing classes LandingEvent and LandingQueue. InYou will need to create files, LandingEvent.h, LandingEvent.cpp, LandingQueue.h and LandingQueue.cpp and add them to the project.
  3. AIRCRAFT: Add one more type of aircraft to the simulation in appropriate .h and .cpp files.

The final simulation is due Friday, December 1.

And, as usual, ... 

Extensions

Once you have met the basic requirements for part II, you are encouraged to extend your program to do more interesting things.  However, before you attempt any extensions, complete the basic requirements and turn in the program as it is.

If you do any extensions, you should include a short writeup summarizing what you did with the turnin receipt that you give to your TA when demonstrating the program.

Use your imagination!!  You could extend the simulation in many ways.  You could use the simulation to model queues at an airport and experiment with different scheduling strategies to minimize takeoff and landing delays.  Or you could turn it into a video game.  Some other ideas:

Program Notes

Download Files

The files for this assignment are available in several formats: an MSVC starter project, a zip file containing only the source files (for people using other systems), and the individual source files as plain test.  There are also sample programs showing how the starter program works without any changes, a sample solution for Part I, and an example showing what the full simulation for Part II could look like.

Sample Programs

Starter Files

Solution Part I

What to Hand In

When you've finished your program, turn in your code using these turning forms.  You can use these turnin forms to turn in the individual source files or  you can create a zip file containing your source files and turn that in.  In either case, do not turn in the gp142 files.  Your program should compile and execute successfully with the original gp142 sources.

  1. Part I: turnin 1 -- due Nov 22 at 1 pm.  Print out the receipt that appears, staple it, and hand it in at the beginning of lecture Nov 22.  You can also put it in the homework drop box on the first floor of Sieg before that time.  No late assignments will be accepted.  Do not plan on coming to class at the end of the hour to hand in your work - the collection boxes will be gone by then. 
  2. Part II: turnin 2 -- due Dec. 1.  Print out the receipt, add to it a description of any extra credit you attempted, staple everything, and bring it with you when you demo your program for a TA.  Details about demos will be announced later.

    Students who have modified GP142 may use this special GP142 turnin form to turn in part II.