-
Notifications
You must be signed in to change notification settings - Fork 0
/
Flight.py
60 lines (53 loc) · 1.5 KB
/
Flight.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import random
import math
from ManagerBase import *
# Flight part
class Flight:
"""
Class representing a flight.
"""
SPEED = 900000 # Boeing 747, m/h
def __init__(self, src, dst, departure_time, cost, index=None):
self._src = src
self._dst = dst
self._departure_time = departure_time
self._cost = cost
self._duration = 0
self._speed = Flight.SPEED
self._duration = src.distance_to_airport(dst) / self._speed
if index is not None:
self._index = index
@property
def src(self):
return self._src
@property
def dst(self):
return self._dst
@property
def departure_time(self):
return self._departure_time
@property
def cost(self):
return self._cost
@property
def duration(self):
return self._duration
@property
def index(self):
return self._index
def set_index(self, index):
self._index = index
def __repr__(self):
return 'Flight {:>3} from {:2} to {:2} @{:5}h for {:7.2f}$ and {:4.2f}h'.format(
'#{}'.format(self._index),
self._src.index,
self._dst.index,
self._departure_time,
self._cost,
self._duration)
class FlightManager(ManagerBase):
"""
Class representing an airport manager.
"""
def __init__(self):
super(FlightManager, self).__init__()