It comes to object-oriented design and is a set of questions that are commonly used in interviews and sections. This is one of those; Unfortunately, my OOP professor in college did not really answer, and so I was thinking.
The problem is as follows: Design the fundamental set of items / methods used to emulate Lift Bank items and their properties / methods.
For logic, let's say we have 20 floors in our building; The floor floor is lobby, and the second floor is attached to the parking garage (so people will exit / exit from the building on the bottom floor or second floor). There is an elevator bank which provides services of all floors;
What is the correct way to model in an object-oriented model?
There are three elevator shafts in the elevator bank,
The first is a lift class, in this one direction (top, bottom, stand , Maintenance), a current floor and a list of floor resolved resolved in the direction. It receives a request from this elevator.
Then the bank has a lift in it and receives the request from the floor. These are all set for active lifts (not in maintenance).
Scheduling will be like this:
- If available, select a permanent elevator on this floor.
- Take an elevator on any other floor.
- Choose a permanent elevator on the other floor.
- Choose lift with the least load.
Each elevator has a set of states
- Maintenance: the elevator does not react to external signals (only for its signals).
- Stand up: Lift has been fixed on one floor if it receives a call and the elevator is on that floor, the doors are open. If it is on the second floor, then it moves in the direction.
- Above: The elevator goes upwards every time it reaches a floor, it checks whether it needs to stop or not. If it is so then it stops and opens the door. It is waiting for a certain time and closes the door (unless something is going through them, then it removes the floor from the request list and checks whether there is any other request. If this happens then the lift starts again.Second stand.
- Below: On top of the reverse direction.
There are additional signals:
- Alarm. And if it's on a floor, the doors are open, follow The list has been approved, the requests went back to the bank.
- Open Doors, if any elevator is on the floor and not.
- The door closes, if they open Then the door is closed.
EDIT: In case of some lifts, the start / bottom_fluend does not start in the skyscrapers.
min_floor There are two additional properties for max_floor elevator.
Comments
Post a Comment