https://github.com/arjunattam/elevator-simulation
https://github.com/arjunattam/elevator-simulation
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/arjunattam/elevator-simulation
- Owner: arjunattam
- Created: 2016-01-30T05:53:45.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-02-01T06:48:28.000Z (over 10 years ago)
- Last Synced: 2024-10-18T07:17:42.905Z (over 1 year ago)
- Language: JavaScript
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# elevator-simulation
## Problem statement
Simplified elevator simulation to implement abstract method in object oriented design.
## Solution
### Summary
The solution has been deployed on Github pages, [link](http://arjun27.github.io/elevator-simulation/). Javascript prototypes have been used to define classes, their properties and methods. The solution is generalized, to __n floors__ and __m elevators__.
The implementation is restricted to floor buttons only, and jobs are given to idle elevators only.
### OOP design
There are 4 classes defined in this implementation. Their properties and methods are detailed below.
* __Controller__
This is the main controller/logic class, responsible for defining _n floors_ and _m elevators_. The Controller class also defines an abstract method _buttonPressed_ which is defined later in the Button class. Job requests are handled with the _handleRequest_ method.
* __Button__
This class defines a floor button, which inherits from the Controller class and defines the _buttonPressed_ capability of the abstract method.
* __Floor__
This class defines a floor, with characteristics of having 2 buttons (_upButton_ and _downButton_) and an identifier number, _floorNum_.
* __Elevator__
This class defines an elevator, with characteristics of current _idleFloor_ and movement of _direction_, which are typically displayed on the elevator status screens. In addition, there is an identifier number, _elevatorNum_.
The _isEligible_ method checks whether the elevator is fit to take up a job, while the _assignJob_ method takes a job and moves the elevator accordingly.