The Elevator Problem

Problem Specification:

You have been hired by the university to build a controller for an elevator in the 10 storied administration building. The elevator is represented as a thread. Each person boarding or leaving the elevator is also represented by a thread. You would need to implement the methods called by the arriving person. e.g. a method ArrivingGoingFromTo(int atFloor, int toFloor) should wake up the elevator (if necessary) and tell it which floor to go to. The elevator is fast but it is not instantaneous, it takes only 100 ticks to go from one floor to the adjacent one. For simplicity, you can assume the following:
You have to come up with a way of storing the requests to the elevator e.g. if a person is accessing the elevator at the 3rd floor and some body is trying to get access from the 5th floor then latter person has to wait before he could place his request. In other words (s)he has to be put in a queue.  Also if the elevator is going upwards all the requests for the destinations downwards should not be accepted until it starts its downward motion and vice versa.

These specifications are for the "vanilla option" of the implementation.  Any form of creativity that you feel like putting in that will add interest to my marking of the project (GUIs, multiple elevators, 'smart' elevators etc) is encouraged.  The marks awarded for the project will reflect this.

The assignment has to be done in Java.

 

Hint:

The program will have two major classes “elevator” and “person” both of which will extend the Java thread class (or extend runnable interface).  Each "person" should be generated with a random arrival time, arrival floor and destination floor and have a unique ID for identification purposes.

In order to simulate the 100 ticks between the two consecutive floors, you can use the  “wait (100)” construct. You can refer to the website http://java.sun.com/docs/books/tutorial/essential/threads/waitAndNotify.html for details of how to use “wait” for this purpose.

You can assume 100 ticks is equivalent to your 1 unit of time (discussed above).

In order to compile a java code, you first have to run the java compiler with “javac <filename>“ and after it gets compiled execute it with “java <filename(executable)>”.

Command line parameters are permissable.

Output file:

The format for the output file should be something like following.

Person (Thread ID) # makes request at time # starting at floor # with the destination floor #.

There should be as many lines printed as are the number of requests.  You should also generate an output file output.dat to store your output.

Note: You must assume that you the starting time for the first request is 0.
 

Deliverables and instructions for submission:

  1. Please also write a short (5 page max) design documentation which may get you some partial credit if your program does not execute.
  2. You have to turn in all you source files, documentation and also all the generated class files for the unix platform.
  3. Mail the above to me with a statement that you have done it yourself except the parts where otherwise stated and that you are aware of the University rules concerning plagiarism at http://www.compapp.dcu.ie/current/policy/plagiarism.htm
  4. Deadline for submission is the last friday of semester eg Friday 19th of December at 5.00pm.  This is a hard deadline and marks will be docked at the rate of 10% per day for latecomers.
Good luck!