-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoom.java
More file actions
103 lines (84 loc) · 2.66 KB
/
Room.java
File metadata and controls
103 lines (84 loc) · 2.66 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
public class Room<T1, T2> {
private int roomNumber;
private int capacity;
private String roomType;
private Graph<T1, T2> patientsGraph;
private ArrayList<T1> patients;
private ArrayList<T2> doctors;
public Room(int roomNumber, int capacity, String roomType) {
this.roomNumber = roomNumber;
setCapacity(capacity);
this.roomType = roomType;
patientsGraph = new Graph<>();
patients = new ArrayList<>();
doctors = new ArrayList<>();
}
public int getRoomNumber() {
return roomNumber;
}
public int getCapacity() {
return capacity;
}
public void setCapacity(int capacity) {
this.capacity = capacity;
}
public String getRoomType() {
return roomType;
}
public void addPatient(T1 patient) {
patientsGraph.addVertex(patient);
if (patient instanceof Patients) {
patients.add(patient);
}
}
public void removePatient(T1 patient) {
patientsGraph.removeVertex(patient);
if (patient instanceof Patients) {
patients.remove(patient);
}
}
public void addDoctor(T2 doctor) {
patientsGraph.addVertex1(doctor);
if (doctor instanceof Doctors) {
doctors.add(doctor);
}
}
public void removeDoctor(T2 doctor) {
patientsGraph.removeVertex1(doctor);
if (doctor instanceof Doctors) {
doctors.remove(doctor);
}
}
public void assignPatient(T1 patient, T2 doctor) {
patientsGraph.addEdge(patient,doctor);
}
public ArrayList<T1> getPatients() {
return patients;
}
public ArrayList<T2> getDoctors() {
return doctors;
}
public Doctors findDoctorByName(String name) {
for (int i = 0; i < doctors.size(); i++) {
Doctors doctor = (Doctors) doctors.get(i);
if (doctor.getName().equals(name)) {
return doctor;
}
}
return null; // doctor not found
}
public Patients findPatientByName(String name) {
for (int i = 0; i < patients.size(); i++) {
Patients patient = (Patients) patients.get(i);
if (patient.getName().equals(name)) {
return patient;
}
}
return null; // patient not found
}
public String toString() {
return "\033[33mRoom Number\033[0m: " + roomNumber +
"\033[33m No.Of Beds:\033[0m " + capacity +
"\033[33m Room Type:\033[0m " + roomType;
}
}