I created an array of List treatto show 5 instances of the treatment room, I also created a linked list inTreatmentfor the treatment room to pass 5 objects to the patient queue, however when I skip several objects in linkedList they constantly replace the first element added instead of going to the next available element . I believe the problem is the row inTreatment.add, but I'm not sure how to reference the next available index. All suggestions are more than welcome. Below is my code for creating an array and adding to a inTreatmentlinkedList.
Creating an array of processed rooms
public static void createTreatmentRooms() {
for (int i = 0; i < treat.length; i++) {
treat[i] = new TreatmentRoom();
treat[i].setAvailable(true);
}
}
Add to treatment procedures
for (int i = 0; i < TreatmentRoom.treat.length; i++) {
if ((TreatmentRoom.treat[i].isAvailable())
&& (Queue.queue.size() != 0)
&& (Queue.queue.getFirst().getTriage() != Status.NOT_ASSESSED)) {
inTreatment.add(queue.getFirst());
System.out.println("taken to treatment queue");
for (Patient p : queue) {
System.out.println(p.getFirstName());
}
queue.poll();
System.out.println("second queue");
for (Patient p : queue) {
System.out.println(p.getFirstName());
}
System.out.println("removed from queue");
TreatmentRoom.treat[i].setPatient(inTreatment.getFirst());
System.out.println("sent to treatment room"
+ TreatmentRoom.treat[i]);
TreatmentRoom.treat[i].setAvailable(false);
System.out.println("treatment room busy");
} else {
System.out.println("Treatment room is not available");
}
}
}