-
Notifications
You must be signed in to change notification settings - Fork 0
/
Employee.py
45 lines (36 loc) · 1.31 KB
/
Employee.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from time import sleep
from uuid import uuid4
from modules.Tickets.Ticket import Ticket
class Employee:
def __init__(self, name: str, salary: float, position: str, experience: int = 1):
self.id = uuid4()
self.name = name
self.experience = experience # 1 to 10
self.salary = salary
self.position = position
self.is_free = True
def calculate_sleep_time(self, ticket: Ticket) -> int:
base_time = 1
return base_time * ticket.target_difficulty / self.experience
def assign_case(self, ticket: Ticket, callback):
self.is_free = False
result = self.handle_ticket(ticket)
callback(result, self, ticket)
def handle_ticket(self, ticket: Ticket):
ticket.start(self)
if not self.can_handle_task(ticket.difficulty):
self.is_free = True
return False
sleep(self.calculate_sleep_time(ticket))
if self.can_handle_task(ticket.target_difficulty):
ticket.close(self)
self.is_free = True
return True
else:
ticket.escalate()
self.is_free = True
return False
def can_handle_task(self, difficulty) -> bool:
if difficulty in self.handle_difficulty:
return True
return False