Get Instant Help From 5000+ Experts For
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
myassignmenthelp.com
loader
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Guaranteed Higher Grade!
Free Quote
wave
COMP 2140 Assignment Guidelines

Instructions

*You must complete the “Honesty Declaration” checklist on the course website before you can submit any assignment.


?*Assignments must follow the programming standards document published on UM Learn.


?*After the due date and time, assignments may be submitted, but will be subject to a late penalty. Please see the course outline document published on UM Learn for the course policy for late submissions.


?*If you make multiple submissions, only the most recent version (the last submission) will be marked. We strongly encourage you to submit early!


?*These assignments are your chance to learn the material for the exams. Code your assignments independently. We use software to compare all submitted assignments to each other, and pursue academic dishonesty vigorously.


?*You can get help from the T.A. during your lab section and from the instructors and from the course Assignment 5 discussion forum on UM Learn. You can discuss general topics related to the assignment with fellow students or other people, but you cannot discuss the solution to the assignment with them.


*You cannot copy code from anywhere except COMP 2140 class notes, unless we tell you otherwise. For a full discussion of our expectations for individual work on this assignment, see the Department of Computer Science’s expectations webpage.


?*Your Java program must compile and run upon download, without requiring any modifications. The marker will not fix your program’s problems.

Part 1 (Programming): Waiting to See a Doctor at an ER

Objective: To simulate patients in an Emergency Room (ER) waiting room.

The application and the file you will complete: The file A05.java contains an incomplete application that simulates patients arriving at and leaving an ER.

The application creates a priority queue to represent the waiting room of the ER for a hospital. Then it randomly generates some events:

*A new patient arrives at the ER. The triage nurse assigns the new patient the next available patient ID and an appropriate priority (based on the patient’s complaint and condition). The patient then waits in the waiting room.

*The highest-priority patient leaves the waiting room to see a doctor.
*A patient leaves the hospital without seeing a doctor.
*A patient’s condition changes, so the triage nurse changes the patient’s priority.

 After all the randomly-generated events have been handled, the application prints out some statistics.

Representing a patient and the waiting room: A patient is represented by a Patient object, which contains a patient ID and a priority (both ints). You can get the ID or the priority, and you can change a priority.

The waiting room is represented by a TriagePriorityQueue, which is implemented as a max heap with all the usual methods, plus some non-standard methods. The heap array in this implementation is an array of Patient objects.

The TriagePriorityQueue methods you will write: You will write the bodies of two non-standard methods in TriagePriorityQueue to complete the application. Do not change anything else in the file.

*Method isHeapOrdered needs to return true if the calling TriagePriorityQueue array is in heap order and false if it isn’t. It has to check that every parent is in heap order with respect to its children (or child, if it only has one).

*Method changePriority is passed the ID number of a patient in the waiting room and a new priority for that patient. This method has two parts: a non-standard part (finding the patient with the given ID in the heap in a linear search and changing that patient’s priority to the new priority) and a standard part (restoring heap order). Hint: Use already-written helper methods to find the patient and to restore heap order — you just have to figure out when and how to call them.

In both these method bodies, if there is already a TriagePriorityQueue method to do something you need to do, then you should use the existing method. So look at the existing methods and do not duplicate code!

support
close