-
Notifications
You must be signed in to change notification settings - Fork 56
/
bridge.py
54 lines (36 loc) · 1.03 KB
/
bridge.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
import abc
class HandsetSoft:
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def run(self):
"""soft run"""
class HandsetGame(HandsetSoft):
def run(self):
print "run game"
class HandsetAddressList(HandsetSoft):
def run(self):
print "run address list"
class HandsetBrand:
__metaclass__ = abc.ABCMeta
def __init__(self, s):
self.soft = s
@abc.abstractmethod
def run(self):
"""run"""
class HandsetBrandM(HandsetBrand):
def run(self):
print "handset brand M : ",
self.soft.run()
class HandsetBrandN(HandsetBrand):
def run(self):
print "handset brand N : ",
self.soft.run()
if __name__ == "__main__":
handset_brand_m = HandsetBrandM(HandsetGame())
handset_brand_m.run()
handset_brand_m = HandsetBrandM(HandsetAddressList())
handset_brand_m.run()
handset_brand_n = HandsetBrandN(HandsetGame())
handset_brand_n.run()
handset_brand_n = HandsetBrandN(HandsetAddressList())
handset_brand_n.run()