-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSubwayPrinter.py
More file actions
37 lines (32 loc) · 1.3 KB
/
SubwayPrinter.py
File metadata and controls
37 lines (32 loc) · 1.3 KB
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
class SubwayPrinter(object):
def __init__(self):
pass
def print_directions(self, route):
connection = route[0]
station1 = connection.get_station1()
station2 = connection.get_station2()
current_line = connection.get_line()
previous_line = current_line
print "Start out at %s." % (station1.get_name())
print
print "Get on the %s heading towards %s." % \
(current_line, station2.get_name())
print
for index in range(1, len(route)):
connection = route[index]
current_line = connection.get_line()
station1 = connection.get_station1()
station2 = connection.get_station2()
if current_line == previous_line:
print "Continue past %s..." % (station1.get_name())
print
else:
print "When you get to %s, get off the %s." % \
(station1.get_name(), previous_line)
print
print "Switch over to the %s, heading towards %s." % \
(current_line, station2.get_name())
print
previous_line = current_line
print "Get off at %s and enjoy yourself!" % (station2.get_name())
print