-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHospital.java
More file actions
89 lines (68 loc) · 1.95 KB
/
Hospital.java
File metadata and controls
89 lines (68 loc) · 1.95 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
public class Hospital {
private ArrayList<Patients> patients;
private ArrayList<Doctors> doctors;
public Hospital(){
patients=new ArrayList<>();
doctors=new ArrayList<>();
}
public void addPatient(Patients patient){
patients.add(patient);
}
public void addDoctor(Doctors doctor){
doctors.add(doctor);
}
public void removeDoctor(Doctors doctor){
doctors.remove(doctor);
}
public void removePatient(Patients patient){
patients.remove(patient);
}
public ArrayList<Patients> getPatient(){
return patients;
}
public ArrayList<Doctors> getDoctor(){
return doctors;
}
public boolean isEmptyPatients(){
return patients.isEmpty();
}
public boolean isEmptyDoctor(){
return doctors.isEmpty();
}
public Patients findPatientByName(String name) {
for (int i = 0; i < patients.size(); i++) {
Patients patient = patients.get(i);
if (patient.getName().equals(name)) {
return patient;
}
}
return null; // patient not found
}
public Patients findPatientById(int id) {
for (int i = 0; i < patients.size(); i++) {
Patients patient = patients.get(i);
if (patient.getId() == id) {
return patient;
}
}
return null; // patient not found
}
public Doctors findDoctorByName(String name) {
for (int i = 0; i < doctors.size(); i++) {
Doctors doctor = doctors.get(i);
if (doctor.getName().equals(name)) {
return doctor;
}
}
return null; // doctor not found
}
public Doctors findDoctorById(int id) {
for (int i = 0; i < doctors.size(); i++) {
Doctors doctor = doctors.get(i);
if (doctor.getId() == id) {
return doctor;
}
}
return null; // doctor not found
}
}