Starting from:

$29.99

Assignment 6: The Emergency Room

Assignment6: TheEmergencyRoom
Objectives
Upon completion of this assignment, you need to be able to: • Create a binary tree using a Vector, which is Java’s version of a resizable array. • Create a version of the PriorityQueue ADT, using a Heap. • Apply data abstraction, hiding a complex data type inside a simpler ADT. • Continue to apply principles of inheritance, encapsulation and modularity. • Continue to apply good programming practice in – designing programs, – proper documentation, and – testing and debugging code.
References: • CSC115 Java coding conventions. • Textbook Chapter 12. • The specification pages provided. Introduction
A group of patients are sitting in the local hospital’s Emergency waiting room, when the attendingERphysicianarrivesforhershift.Thetriagenursehasalreadyassessedpatients bytheirmaincomplaintandprovidesanelectronicdevicewherebythephysiciancantouch the screen and the next patient chart is provided. The ordering of the charts is determined
by the patient’s priority and then time of check-in. You have been tasked with the part of thesoftwarethatstoresthepatientinformationandprioritizesthelistfortheERphysician. Theprojectleaderhaselectedtouseapriorityqueuebasedonanarray-basedheaptostore the ER Patient objects.
QuickStart
(1) Create a fresh directory to contain this assignment: CSC115/assn6 is a recommended name. Download this pdf file and the .java files to this directory. (2) Download and extract the javafiles.zip and docs.zip in the same directory. A docsdirectorywillbecreatedtostorethespecificationsforthepublicclasses.Allthe documentlinksinthisdocumentareaccessibleiftheyarestoredinthe docs directory local to this pdf file. A light blue text segment indicates a link. (3) The following files are complete: • ER Patient.java • NoSuchCategoryException.html (4) The following files are partially done and need to be completed: • Heap.java • PriorityQueue.java DescriptionsoftheHelperClasses
Chapter 12 of the textbook provides most of the background on the array-based heap and the priority queue ADT. Note that within the PriorityQueue, the Heap is completely hiddenfromtheuser,invokingtheinformation-hidingaspectsofO-Oprogramming.
DetailedstepstocompletingtheHeapclass:
(1) The shell is provided for this class. Fill in the comments above each of the public methods and write the code that makes these methods work. (2) Add additional data fields as necessary. Add additional private methods that help maintainboththeorderingoftheHeaparrayduringinsertsandremovals.Aprivate print-outofthearrayisalwaysrecommended,asareseparatemethodsforbubbling an item upwards or downwards.
(3) You must not change the provided method headers or the given data fields. There are two reasons for this requirement: (a) You are a programmer on a team; others are expecting their code to plug into your code. (b) YourareastudentinCSC115,doinganexercisethatenhancesyourskillsasa programmer.Toobtainadequatefeedback,themarker(s)arecountingoneasy access to your implementation. (4) Why are we using a java.util.Vector instead of basic array? Arrays in Java wereoriginallycopiedfromtheCprogramminglanguage.TheybehaveasObjects but do not follow the standard rules for proper O-O programming. Once Java introduced generics, the array was left behind. There is no way to create a basic array that handles generic objects. The Vector class has all the functionality of a resizable array AND it can handle generic objects. (5) You must test every method internally. The more rigorously you test, the more robust your code. Do not move to the next step until you are confident that the Heap works as expected. • Note that the ER Patient internal class uses Thread.sleep() to spread a singlesecondbetweenadmittimes.Youmayusethistechniqueorchoosethe constructortocreateyourownadmittimes.Forthesakeofthemarker’ssanit, DO NOT use Thread.sleep in any method other than main.
DetailedstepstocompletingthePriorityQueueclass:
(1) The shell is provided for this class. Fill in the comments above each of the public methods and write the code that makes these methods work. (2) Let the hidden Heap data structure do all the work in each of the PriorityQueue methods. (3) Testthe PriorityQueue.Ifthe Heap hasbeenthoroughlytested,itissufficientto insert a few patients and then dequeue and print until the queue is empty. A sorted print-out indicates success.
AnoteabouttheHeapvs.thePriroityQueue:
A PriorityQueue can use a linked data structure, an un-ordered array, an ordered array, or a tree as its underlying data structure. We use the Heap in this exercise, because the
Heap data structure is so beautifully similar to the PriorityQueue and takes O(log n) for both insert and remove operations. However, the Heap is a complete binary tree data structure and is not necessarily bound by the PriorityQueue’s interface definitions. For instance,itisallowedtohaveaniteratoranditisallowedtohavea size method.Thereis alsonothingstoppinga Heap fromdeletinganiteminthemiddleofitsstructure,although there are better data structures for that kind of operation. The PriorityQueue ADT is much more limiting. For that reason, you want to make sure that the user does not ever have access to the Heap itself. It is desirable to have the PriorityQueue hide any extra functionality of the Heap.
Submission
Submit the following completed files to the Assignment folder on conneX. • Heap.java • PriorityQueue.java Please make sure you have submitted the required file(s) and conneX has sent you a confirmation email. Do not send [.class] (the byte code) files. Also, make sure you submit your assignment, not just save a draft. Draft copies are not made available to the instructors, so they are not collected with the other submissions. We can find your draft submission,, but only if we know that it’s there.

Grading
Marks are allocated for the following: • Proper programming style is demnstrated, as per the coding conventions on CSC115 conneX Resources. All instruction comments must be removed from the code. • Source code that follows the specifications and instructions. • Heap uses a Vector as its main data field. • Good data abstraction: well-defined Heap and PriorityQueue.
• Good modularity: well-defined helper methods. • Internal testing: using the main method as a test harness. • You will receive no marks for any Java files that do not compile.

More products