-
Notifications
You must be signed in to change notification settings - Fork 0
/
Doctor.py
47 lines (37 loc) · 1.46 KB
/
Doctor.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
from Patient import *
class Doctor:
"""
A class to simulate a doctor treating patients in a clinic
"""
def __init__(self, rate):
"""
The doctor is initialized with the rate of treating patients, and NO current patients
:param rate: the rate of treating patients
"""
self.patientRate = rate
self.timeRemaining = 0
self.currentPatient = None
def enterNextPatient(self, patient):
"""
This Method simulates the entering of the patients to the doctor
:param patient: the next patient according to the queue (object of class Patient)
:return: No return value
"""
self.currentPatient = patient
# Time taken to treat each patient = Age/5 or Age/10 (* 60 to get it in seconds)
self.timeRemaining = round(patient.getAge()/self.patientRate) * 60
def busy(self):
"""
Method to check whether the doctor is free or not
:return: boolean value (True if busy, False if not)
"""
return self.currentPatient is not None
def tick(self):
"""
This method simulates the clock in the clinic, one call for this method means that 1 second has passed
:return: No return value
"""
if self.currentPatient is not None:
self.timeRemaining -= 1
if self.timeRemaining == 0:
self.currentPatient = None