-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path09-Hospital.py
More file actions
executable file
·42 lines (37 loc) · 1.29 KB
/
Copy path09-Hospital.py
File metadata and controls
executable file
·42 lines (37 loc) · 1.29 KB
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
class Patient(object):
def __init__(self,uid,name,allergies):
self.uid = uid
self.name = name
self.allergies = allergies
self.bed = "none"
class Hospital(object):
def __init__(self,name,cap):
self.patients = []
self.name = name
self.capacity = cap
def admit(self,patient):
if type(patient) != Patient:return
if len(self.patients) >= self.capacity:
return "The hospital is at maximum capacity"
else:
patient.bed = len(self.patients)
self.patients.append(patient)
return "Admission complete"
def discharge(self,uid):
patient = 0
for key in range(0,len(self.patients)-1):
patient = self.patients[key]
if uid == patient.uid:
print "Removed: "+patient.name
patient.bed = "none"
return self.patients.pop(key)
patient1 = Patient(0,"Bob","Peanuts,Fish")
patient2 = Patient(1,"Bill","Milk,Cheese")
patient3 = Patient(2,"Rick","Beef,Ham")
patient4 = Patient(3,"Sue","Cotton,Copper")
hospital = Hospital("Kaiser",3)
print hospital.admit(patient1)
print hospital.admit(patient2)
print hospital.admit(patient3)
print hospital.admit(patient4)
print hospital.discharge(1).name