-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathproblem5.py
44 lines (32 loc) · 929 Bytes
/
problem5.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
import time
class Counselor:
def __init__(self):
self.busy = False
def talk(self):
print("I am ready to talk")
class PhoneCall:
def __init__(self, current_time='weekdays'):
self.counselors = [Counselor(), Counselor()]
self.current_time = current_time
def talk(self):
if self.current_time == 'weekdays':
# TODO: fill this function
# If you want, you can add time.sleep(0.1) before you call talk() in Counselor
# to simulate the waiting time.
else:
time.sleep(0.1)
print('Counselor will not talk to you')
if __name__ == "__main__":
p = PhoneCall('weekdays')
p.talk()
p.talk()
p.talk()
p = PhoneCall('weekend')
p.talk()
"""
Expected Output
> I am ready to talk
> I am ready to talk
> No available counselor
> Counselor will not talk to you
"""