File tree Expand file tree Collapse file tree 1 file changed +84
-0
lines changed
Expand file tree Collapse file tree 1 file changed +84
-0
lines changed Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # encoding: utf-8
3+
4+ """
5+ @author: zhanghe
6+ @software: PyCharm
7+ @file: test_oop.py
8+ @time: 2017/7/25 下午6:10
9+ """
10+
11+
12+ class A (object ):
13+ def go (self ):
14+ print "go A go!"
15+
16+ def stop (self ):
17+ print "stop A stop!"
18+
19+ def pause (self ):
20+ raise Exception ("Not Implemented" )
21+
22+
23+ class B (A ):
24+ def go (self ):
25+ super (B , self ).go ()
26+ print "go B go!"
27+
28+
29+ class C (A ):
30+ def go (self ):
31+ super (C , self ).go ()
32+ print "go C go!"
33+
34+ def stop (self ):
35+ super (C , self ).stop ()
36+ print "stop C stop!"
37+
38+
39+ class D (B , C ):
40+ def go (self ):
41+ super (D , self ).go ()
42+ print "go D go!"
43+
44+ def stop (self ):
45+ super (D , self ).stop ()
46+ print "stop D stop!"
47+
48+ def pause (self ):
49+ print "wait D wait!"
50+
51+
52+ class E (B , C ):
53+ pass
54+
55+
56+ a = A ()
57+ b = B ()
58+ c = C ()
59+ d = D ()
60+ e = E ()
61+
62+ # 说明下列代码的输出结果
63+
64+ a .go ()
65+ b .go ()
66+ c .go ()
67+ d .go ()
68+ e .go ()
69+
70+ a .stop ()
71+ b .stop ()
72+ c .stop ()
73+ d .stop ()
74+ e .stop ()
75+
76+ a .pause ()
77+ b .pause ()
78+ c .pause ()
79+ d .pause ()
80+ e .pause ()
81+
82+
83+ if __name__ == '__main__' :
84+ pass
You can’t perform that action at this time.
0 commit comments