Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PLEASE follow sample output public class Patient{ //attributes private String name; private int order; //order of arrival private int emergency; //1 is normal, 5 is
PLEASE follow sample output
public class Patient{ //attributes private String name; private int order; //order of arrival private int emergency; //1 is normal, 5 is life-and-death situation //constructor public Patient(int order, String name, int priority) { this.order = order; this.name = name; this.emergency = priority; } //getters and setters public int getOrder() { return order; } public void setOrder(int order) { this.order = order; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getEmergency() { return emergency; } public void setEmergency(int emergency) { this.emergency = emergency; } public String toString() { return name; } }Focus: Java Collection Framework In this assignment, you are required to write a menu-driven Java program that allows the user to add patients to a priority queue, displaythe next patient (and remove him/her from the queue), show a list of all patients currently waiting for treatment, and exit the program. The program should simulate the scheduling of patients in a clinic. Use the attached Patient class provided along with this assignment Your program should schedule patients in the queue according to the emergency of their cases from 1 to 5 (the higher the value, the higher the priority). If two patients have the same emergency value, use their order of arrival to set their priority (the lower the order, the higher the priority). It is up to you to have the Patient class implement either Comparable or Comparator Create a class PatientManager that has an attribute named waitingList of the type PriorityQueue Patient and a public method, start When start is called, it should display the following menu of choices to the user, and then ask the user to enter a choice from 1 to 4: (1) New Patien 2) Next Patient (3) Waiting List (4) Exit Here is a description of each choice: (1) Ask the user for the patient's name and the emergency from 1 to 5 (1 ow, and 5 fe and-death). Your program should create an instance of Patient using the entered data and add it to the priority queue. Note that your program should not askthe user for the value of the patient's order of arrival. Instead, it should use a counter that is automatically incremented whenever a patient is added to the queue (2) Display the name of the next patient in the priority queue and remove him/her from the queue (3) Display the full list of all patients that are still in the queue. (4) End the program. Make sure your PatientManager class is robust. It should not crash when a user enters invalid value. Instead, it should display an error message followed by an action depending on the type of error (see the sample run below) Test your program by instantiating your PatientManager class in a main method and calling the start method Note: Add more helper methods and attributes as needed to the PatientManager class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started