-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp1115.py
93 lines (78 loc) · 2.31 KB
/
p1115.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
##class Product:
## """
## doc_doc_doc
## """
## name = ''
## price = 0
##
## def __init__(self, name, price):
## self.name = name
## self.price = price
##
## def __lt__(self, other):
## return self.price < other.price
##
## def __le__(self, other):
## return self.price <= other.price
##
## def __gt__(self, other):
## return self.price > other.price
##
## def __ge__(self, other):
## return self.price >= other.price
##
## def __eq__(self, other):
## return self.price == other.price
##
## def __ne__(self, other):
## return self.price != other.price
##
## def __repr__(self, other):
## return self.price != other.price
##
## def __str__(self):
## return "price is %s name is %s "%(self.price, self.name)
##
## def __repr__(self):
## return "name is %s !!!"%self.name
##
## def __add__(self, tax):
## return self.price + tax
##
## def __sub__(self, disc):
## return self.price - disc
class Line:
name = "vertical_line"
length = 200
number_of_stations = 0
stations = []
arrive_time = 0
def __init__(self, name, stations):
self.name = name
self.stations = stations
def find_transfer(self):
for s in self.stations:
if s.transfer_station:
return s
def same_line_stations(self, station1, station2, car):
if station1 in self.stations and station2 in self.stations:
return self.calc_time(station1, station2, car)
elif station1 in self.stations:
return self.calc_time(station1, self.find_transfer(), car)
elif station2 in self.stations:
return self.calc_time(station2, self.find_transfer(), car)
else:
return "something went wrong"
def calc_time(self, station1, station2, car):
return (station1.position - station2.position)/car.speed
class Station:
name = ""
uid = 0
position = 0
start_station = False
end_station = False
transfer_station = False
def __init__(self, name, point, transfer)
class Car:
uid = 0
speed = 10