-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpacket.py
More file actions
18 lines (16 loc) · 790 Bytes
/
Copy pathpacket.py
File metadata and controls
18 lines (16 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class Packet:
def __init__(self, event_type, arrival_time, length=0, service_time=0):
self.event_type = event_type
self._arrival_time = arrival_time
self._length = length
self._service_time = service_time
self._departure = None
def departure(self, last_departure):
"""Return departure time."""
#If the packet don't have to wait, the departure time is the arrival time plus the service time
if self._arrival_time > last_departure:
self._departure = self._arrival_time + self._service_time
#If the packet have to wait, the departure time is the last departure time plus the service time
else:
self._departure = last_departure + self._service_time
return self._departure