-
Notifications
You must be signed in to change notification settings - Fork 56
/
proxy.py
53 lines (36 loc) · 1.02 KB
/
proxy.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
import abc
class GiveGift:
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def __init__(self, sg):
"""init"""
@abc.abstractmethod
def give_dolls(self):
"""give dolls"""
@abc.abstractmethod
def give_flowers(self):
"""give flowers"""
class SchoolGirl:
def __init__(self, n):
self.name = n
class Pursuit(GiveGift):
def __init__(self, sg):
GiveGift.__init__(self, sg)
self.school_girl = sg
def give_dolls(self):
print "give " + self.school_girl.name + " dolls"
def give_flowers(self):
print "give " + self.school_girl.name + " flowers"
class Proxy(GiveGift):
def __init__(self, sg):
GiveGift.__init__(self, sg)
self.pursuit = Pursuit(sg)
def give_dolls(self):
self.pursuit.give_dolls()
def give_flowers(self):
self.pursuit.give_flowers()
if __name__ == "__main__":
school_girl = SchoolGirl("Alice")
proxy = Proxy(school_girl)
proxy.give_flowers()
proxy.give_dolls()