-
Notifications
You must be signed in to change notification settings - Fork 0
/
passenger.py
25 lines (20 loc) · 868 Bytes
/
passenger.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from dataclasses import dataclass
from pydantic import BaseModel
from elevator_system_design.model.direction import Direction
@dataclass(unsafe_hash=True, frozen=True)
class Passenger(BaseModel):
id: str
source_floor: int
destination_floor: int
request_time: int # the time step at which they requested the elevator
@property
def direction(self) -> Direction:
"""
The function determines the passenger's direction of travel based on the source and destination floors.
:return: the direction in which the passenger wants to move. If the source floor is greater than the destination
floor, it will return Direction.DOWN. Otherwise, it will return Direction.UP.
"""
if self.source_floor > self.destination_floor:
return Direction.DOWN
else:
return Direction.UP