Question
/** * EmergencyTriage.java * Provided the necessary information here, * making sure to delete these lines. */ // This is the beginning of the source
/** * EmergencyTriage.java * Provided the necessary information here, * making sure to delete these lines. */
// This is the beginning of the source code to help you get started. // Do not change the following:
public class EmergencyTriage { private Heap
/** * The empty EmergencyTriage is initialized. */ public EmergencyTriage() { waiting = new Heap(); }
/** * Heap.java * Provide the necessary header information here, * making sure to delete these lines. */
import java.util.List; import java.util.ArrayList; import java.util.NoSuchElementException;
// This is the beginning of the source code to help you get started. // Do not change the following:
public class Heap
private ArrayList
/** * Creates an empty heap. */ public Heap() { heap = new ArrayList /** * NoSuchCategoryException.java */ /** * This exception indicates that the triage category for an ERPatient * not a valid category. * These categories are determined by the ERPatient class. */ public class NoSuchCategoryException extends RuntimeException { /** * Creates a new exception. * @param msg The error message. */ public NoSuchCategoryException(String msg) { super(msg); } /** * Creates a new exception. */ public NoSuchCategoryException() { super(); } } /** * ERPatient.java */ /** * Class ERPatient represents the record of a patient presenting to an Emergency room. * Patients are assessed and registered by the triage nurse, who determines * their level or priority for detailed assessment and treatment in the Emergency Room. */ public class ERPatient implements Comparable private static int admissionNumber = 0; private int orderStamp; private String id; private String lastName; private String firstName; private int priorityNum; protected final static String[] categories = {"Life-threatening","Major fracture","Acute","Chronic","Ambulatory"}; /** * Creates an ER record for the registered patient. * @param lastName The patient's last name. * @param firstName The patient's first and subsequent names. * @param triageCategory: This is the category given by the triage nurse after a preliminary assessment based on the patient's complaint and some vital signs. * The categories used, in order of priority are: * *
*/ public ERPatient(String lastName, String firstName, String triageCategory) { this.lastName = lastName; this.firstName = firstName; orderStamp = admissionNumber++; id = lastName+"_"+orderStamp++; priorityNum = verify_triageCategory(triageCategory); }
private int verify_triageCategory(String triageCategory) { for (int i=0; i private static String categories() { StringBuilder sb = new StringBuilder(10*categories.length); sb.append("Acceptable category list: \t"); for (String s: categories) { sb.append(s+", "); } // the categories are never empty // remove the last comma and space sb.delete(sb.length()-2,sb.length()); return sb.toString(); } /** * Decides which patient has the highest priority level for admission to the * Emergency room. * Priority is determined first by the triage category, and then by the length of time waiting. * @param other The patient record being compared to this patient record. * @return a number 0 indicates that the other patient has higher priority. * If 0, then the two records belong to the same patient. * @throws NullPointerException if other is null. */ public int compareTo(ERPatient other) { if (other == null) { throw new NullPointerException("Cannot compare ERPatient to a null object"); } int triageOrder = priorityNum - other.priorityNum; if (triageOrder == 0) { triageOrder = orderStamp - other.orderStamp; } return triageOrder; } /** * Equality of patient records is determined by id, which indicates that the records * belong to the same person. * @param other The patient record to compare. * @return true if the records are for the same patient; false otherwise. */ public boolean equals(ERPatient other) { return id.equals(other.id); } /** * @return The id number of this patient. */ public String getId() { return id; } /** * @return The priority level assigned the patient. Lower numbers have higher priority. */ public int getPriorityNum() { return priorityNum; } /** * @return The actual triage category that was assigned the patient. */ public String getTriageCategory() { return categories[priorityNum-1]; } /** * @return The patient record information. */ public String toString() { return lastName+", "+firstName+": order number: "+orderStamp+", triage category: "
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