Elevator - Here is the State factory pattern to create the one of the child 1. Floor Button(will contain the list of floor object of strategy based on parameter(can buttons in elevator) be configured in property file) 2. elevator Request it will contain the elevator Direction Based Strategy - requests in ascending order if direction is UP 1. It will check the current State of elevator, otherwise it will contain in descending order 2. If Elev is in Idle state, it will place the floor if direction is DOWN. Request in list named as Elevator Request. 3. Current Direction(UP or DOWN) Else call Elevator Request Manager to place 4. current Floor the request in set(Tree based) pending Requests 5. current State(Running/Idle/Maintenance etc) 3. If Elev is in Running state, it will get the Here is the behavior current Direction . If it matches with Elevator 6. run(...) :- It will process the elevator Request Request direction and current floor is less till it is empty. if list is not empty, it will set its than Elevator Request floor it will place the state to Running , set the direction based on request in floor Request list. Else call comparison of it current Floor and any Elevator Request Manager to place the request in elevator Request and print request in set pending Requests I have running . Tt will also check the each elevator chosen the Tree Set so that request can be Request in list elevator Requests in stored in in order of time and does not sequential order and check if it is equal to contain duplicate entries get current Floor(). If yes print "Reached 4. Process Request(...) Floor" + current Floor. Else make the state Elevator Request Manager- This will place the as Stopped Elevator Request in some data structure like list. 7. set Current Floor() :- Whenever elevator Here we wil two classes Downward Elevator reach to any floor , it will call this method to Request Manager and Upward Elevator Request set the current Floor. Manager 8. Open Door() 1. process Request(...)
9. close Door() 2. process Pending Request(...) This method
will start the thread that will keep on running. 10. reset() This will again use the Direction Based Button - Strategy. This will poll the pending Requests 1. Floor Button (Button inside elevator to place to pick the requests in the same direction elevator request) until the last request in that direction. Once 2. Direction Button(Button outside elevator to all the requests are picked , it will remove the call elevator) requests from pending Requests and put it in Elevator Request elevator Request and call run method on 1. Floor Number elevator. To pick the move direction , it will pick the direction from first request under 2. direction pending Requests(it already contains the 3. time request in time order) Controller/Business Objects :- Elevator Controller - For handling http request and delegate it to Elevator Request Manager 1. process Elevator Request(..) 2. process Floor Request(..) Elevator Schedule Manager - To place the request we can use different kind of strategies like time based, direction based etc. Here i will use Direction Based Strategy. Here is the Direction Based Strategy