-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex45.py
85 lines (44 loc) · 1.6 KB
/
ex45.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
class room(object):
def enter(self):
exit(1)
class Engine(object):
def __init__(self, arrange_room):
self.arrange_room = arrange_room
def go(self):
current_room = self.arrange_room.opening_room()
last_room = self.arrange_room.next_room('room3')
while current_room != last_room:
current_roomname = current_room.enter()
current_room = self.arrange_room.next_room(current_roomname)
current_room.enter
class room1(room):
def enter(self):
print "Attibute Error."
raw_input()
return 'room2'
class room2(room):
def enter(self):
print "But what can I do?"
raw_input()
return 'room3'
class room3(room):
def enter(self):
print "Riddle"
class Map(object):
rooms = {'room1': room1(), 'room2': room2(), 'room3': room3()}
def __init__(self, start_room):
self.start_room = start_room
def next_room(self, room_number):
val = Map.rooms.get(self.room_number)
return val
def opening_room(self):
return self.next_room(self.start_room)
A_map = Map('room1')
A_go = Engine(A_map)
A_go.go()
# 1. I did not put object in class xx(), no : after ()
# 2. I did not put : after while
# 3. did not indent under while.
# 4. did not put : after def openning():
# 5. did not even define any enter() function in each room class..
# 6. import non-exitened modules