CS 680
Spring, 2003
Ethan Bolker
hw9

Due Wednesday, April 23, in class. .

This assignment calls for the first round of the elevator simulation. I've designed it so that you can build a structure into which you can fit the details as they evolve. I've tried to ask for things you can do that you won't have to redo after you get feedback from the last assignment.

The overall architecture has three levels:

  1. A driver, handling input and output.

  2. A model for the elevator system being simulated.

  3. A discrete event simulation package.
Here's what you should do for each of these.

  1. We'll use .els for the file extension for elevator simulation input. Te sample file $CS680/hw9/sample.els specifies the format. It should really be an XML document, but we don't have time to learn how to use the public Java XML tools. Just parse the .els files with a StringTokenizer for each line.

    Write a driver class Simulate with a static main that creates an ElevatorSimulation object, populates it with input data read from file something.els and echoes its input to file something.els.out. The input should be passed on the command line:

    	java Simulate sample.els
    

  2. The top level model object will be an instance of class ElevatorSimulation. An ElevatorSimulation object needs lots of initial state. A constructor with a long list of arguments is not a good idea (says Fowler) so design a very simple constructor and write getters and setters for the initial data. Those getters will be useful later too.

    Write two or three of the top level classes you know you will need.

    One should certainly be the Elevator class. Write a unit test Be sure to keep your unit test up to date as the class evolves. Decide how the ElevatorSimulation will know about its Elevators, create them and make sure the unit test in ElevatorSimulation tests the construction of Elevators.

    Choose another few classes you know you will need and begin them.

    Pay attention to fields, getters and setters. Don't try to implement any logic yet.

  3. The core of the simulation is the code that maintains the event chain. You can find my implementation in $CS680/simulator. The API is in this javadoc. Here is browsable code. Read the API and run the unit test in class Simulate. You should read the unit test too. You can read the rest of the code if you like.

Back to the CS680 home page.