-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPatientManager.java
More file actions
62 lines (56 loc) · 1.44 KB
/
PatientManager.java
File metadata and controls
62 lines (56 loc) · 1.44 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
public class PatientManager {
public Patient[] spots;
public PatientManager(){
this.spots = new Patient[10];
}
public int AddPatient(Patient x){
for(int i = 0; i < 10; i++){
if(spots[i] == null){
spots[i] = x;
return i;
}
}
return -1;
}
public Patient RemovePatient(int y){
if(spots[y] != null){
Patient removedPatient = spots[y];
spots[y] = null;
return removedPatient;
}
else{
return spots[y];
}
}
public void caffeineAbsorption(){
for(int i = 0; i < 10; i++){
if(spots[i] != null){
spots[i].caffeineLvl = spots[i].caffeineLvl - 130;
if(spots[i].caffeineLvl <= 0){
spots[i] = null;
}
}
else{
spots[i] = spots[i];
}
}
}
public String toString(){
int emptyPatients = 0;
String patientData = "";
for(int i = 0; i < 10; i++){
if(spots[i] != null){
patientData += spots[i].idNumber + " " + spots[i].caffeineLvl + "\n";
}
else{
emptyPatients = emptyPatients + 1;
}
}
if(emptyPatients == 10){
return "Empty";
}
else{
return patientData;
}
}
}