File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 55
66
77class SalesManager :
8-
98 def work (self ):
109 print ("Sales Manager working..." )
1110
@@ -14,7 +13,6 @@ def talk(self):
1413
1514
1615class Proxy :
17-
1816 def __init__ (self ):
1917 self .busy = 'No'
2018 self .sales = None
@@ -30,14 +28,32 @@ def work(self):
3028 print ("Sales Manager is busy" )
3129
3230
31+ class NoTalkProxy (Proxy ):
32+ def __init__ (self ):
33+ Proxy .__init__ (self )
34+
35+ def work (self ):
36+ print ("Proxy checking for Sales Manager availability" )
37+ time .sleep (2 )
38+ print ("This Sales Manager will not talk to you whether he/she is busy or not" )
39+
40+
3341if __name__ == '__main__' :
3442 p = Proxy ()
3543 p .work ()
3644 p .busy = 'Yes'
3745 p .work ()
46+ p = NoTalkProxy ()
47+ p .work ()
48+ p .busy = 'Yes'
49+ p .work ()
3850
3951### OUTPUT ###
4052# Proxy checking for Sales Manager availability
4153# Sales Manager ready to talk
4254# Proxy checking for Sales Manager availability
4355# Sales Manager is busy
56+ # Proxy checking for Sales Manager availability
57+ # This Sales Manager will not talk to you whether he/she is busy or not
58+ # Proxy checking for Sales Manager availability
59+ # This Sales Manager will not talk to you whether he/she is busy or not
You can’t perform that action at this time.
0 commit comments