This is a frequently asked question during job interview. The question is, "how do you design a control system for an elevator bank, Assume the controller is receiving messages as text, and sends messages as text. list the objects/methods."
This interview question is very simple to ask but surprisingly difficult to get right. It might involves things like queues and can easily be extended to throw in more challenges. For example, how to reduce wait times, etc.
I should say that this type of interview questions is to test if someone has the right attitude and interest. By asking how they do anything, it will tell you how good they are.
A possible answer to this interview question is as follows.
Elevator class: it has states such as up/down/stand/maintenance, current floor, list of floor requests sorted in the direction.
Elevator bank class: contains elevators and receives requests from the floors. It has scheduling such as:
if available pick a standing elevator for this floor.
else pick an elevator moving to this floor.
else pick a standing elevator on an other floor.
else pick the elevator with the lowest load.
To solve similar problems like this, some computer science interview books on data structures and algorithms could be very helpful. See My List of Recommended Interview Books
for more info.
1. visitor 2011-02-14 06:01
This interview question could use command pattern. The receiver of the command are the elevators. But, the command class/objects are missing in your design.
2. JC 2011-08-18 17:51
To be frank, I hate this type of "design a system for elevators" type of questions. Instead, I more like algorithm or data structure questions, or performance related questions.