-
Notifications
You must be signed in to change notification settings - Fork 0
/
Layer 1.py
56 lines (44 loc) · 1.28 KB
/
Layer 1.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
55
56
import login
import queueing_patient
patient_q = queueing_patient.Queue()
patient_q_priority = queueing_patient.Queue()
def varify_email(email):
'''
str --> bool
'''
for char in email:
if char == '@':
return email[-4:] == '.com'
return False
def queueing(patient):
# true stands for the emergency
if patient.priority:
patient_q_priority.add(patient)
else:
patient_q.add(patient)
def dequeueing():
if patient_q_priority.isEmptyQueue() and not (patient_q.isEmptyQueue()):
return patient_q.retrive()
elif not (patient_q_priority.isEmptyQueue()):
return patient_q_priority.retrive()
if __name__ == '__main__':
p1 = login.Patient("tom", "2000-12-03", "normal")
p2 = login.Patient("jerry", "2000-12-03", "normal")
p3 = login.Patient("yichen", "2000-12-03", "priority")
p4 = login.Patient("himel", "2000-12-03", "priority")
p3.emergency()
p4.emergency()
queueing(p1)
queueing(p2)
queueing(p3)
queueing(p4)
#patient_q.priorized(p3)
#patient_q.priorized(p4)
print("############")
#print(p3)
#print(patient_q)
#print(str(patient_q.retrive()))
print(dequeueing())
print(dequeueing())
print(dequeueing())
print(dequeueing())