Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

help im not sure how to use helper methods and checking user input to make sure the choice is available but also store new patients.

help im not sure how to use helper methods and checking user input to make sure the choice is available but also store new patients.

image text in transcribedimage text in transcribedimage text in transcribed
Import Java. Util .* ; public class PatientManager [ private Priority Queue _ Patient _ waitingList = new Priority Queue _ Patient _ !) ; public static void startis [ Scanner in = new Scanner [ System . in) ; System . out . printIn` " _ _ _ _ _ _ - - - "^ System . out . printIng" (1) New Patient" + "nice; Next Patient " + " nez's Waiting List " + "`n[A] Exit") ; System . out . printIn[" _ _ _ _ _ _ _ boolean vaild = false" whilerivaild; [ System . out . printIn"* Choose an Item From the MENU : "` int choice = in . nextInt!) ; if [ start ( choice ) _ _ true ) [ public static boolean start( int is [ boolean [ !` if [i _ _ Illi _ _ 21/ 1 _ 31 1 1 _ _ 4) [ [_true; return [is ELSE return false :In this assignment , you are required to write a menu- driven Java program that allows the user to add patients to a priority queue , display the next patient land 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, I 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 Patient Manager that has an attribute named waiting List of the type Priorit Y Queue - Patient" and a public method , start Il . 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) ( 2 ) How Patient . Next Patient ( 3 ) ( 4) waiting List . Exit . Here is a description of each choice ! |1 1 Ask the user for the patient's name and the emergency from 1 to 5. 1 1 = low , and 5 = life- 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 ask the 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 . 12) Display the name of the next patient in the priority queue and remove him / her from the QUEUE . 131 Display the full list of all patients that are still in the queue . 14) 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 ISEE 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 PatientManage - classSample run (Read carefully to determine the required response in different situations ! ( 1) New Patient . ( 2 ) ( 3 ) Next Patient* Waiting List . Exit . . Choose an item from the menu ! {} ( * ) Wrong choice . * Choose an Item from the menu ; two` ( x ) Wrong choice . " Choose an item from the menu ! ?" . No more patients .` * Choose an item from the menu ; ]` . No patients in the list .` * Choose an item from the menu : !` Enter patient's name ; Abdallah Enter Emergency [ I (low) to 5 ( life - and - death ; ] : {` ( *) Wrong Vallur . Try again. critical ( * ) Wrong Value . Try again . I Patient added to the waiting list . * Choose an item from the menu : 1 Enter patient " & name : John* Enter Emergency [ I ( low) to 5 ( life_ and _ death; ] : `` Patient added to the waiting list . { Choose an item from the menu ; ]] Waiting list includes :" . John = Abdallah & Choose an item from the menu ; ] Enter patient " & name : Lill* Enter Emergency [ I ( low's to 5 ( life_and _ death ; ] : 4\\ Patient added to the waiting list . * Choose an item from the menu ; ]` Waiting list includes :" - John _ LILI - Abdallah * Choose an item from the menu ; 2) - John is treated . * Choose an item from the menu !` = Lill is treated .` . Choose an item from the menu : 2 = Abdallah is treated .` & Choose an item from the menu :``

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions

Question

What is the refractive index of the cornea....?

Answered: 1 week ago

Question

Common defects of the eye?

Answered: 1 week ago

Question

The eye is responsible for producing tears....?

Answered: 1 week ago

Question

Cause on the an increase in pressure with in the eye ?

Answered: 1 week ago

Question

What is the Normal Eye Power ?

Answered: 1 week ago