Question: ***FILL IN THE PROVIDED CODE IN JAVA, WITH ONLY FILE 3 NEEDING TO BE FILLED *** Objective: Consider records for patients at a medical facility.
***FILL IN THE PROVIDED CODE IN JAVA, WITH ONLY FILE 3 NEEDING TO BE FILLED ***
Objective: Consider records for patients at a medical facility. Each record contains an integer identification for a patient and strings for the date, the reason for the visit, and the treatment prescribed. Design and implement the class PatientRecord so that it overrides the method hashCode. A program that tests your new class is provided. The code for this part is in the ZIP archive. Your programs output must be identical to the output of the sample run:?

File 1: BadVisitDateException
/** * DO NOT CHANGE * * Visit record could not be created * when the date information was invalid. */ public class BadVisitDateException extends Exception { public BadVisitDateException(String reason) { super(reason); } } File 2: Driver
/** * * DO NOT CHANGE * * A driver for the class PatientRecord. */ public class Driver { public static void main(String args[]) { PatientRecord test1; PatientRecord test2; try { test1 = new PatientRecord(101, 12, 15, 2006, "cough", "bed rest"); System.out.println("Patient Record created: " + test1); System.out.println("It has hash code " + test1.hashCode()); } catch (BadVisitDateException e) { System.out.println("Creation failed " + e); } try { test2 = new PatientRecord(101, 12, 17, 2006, "high fever", "antibiotics"); System.out.println("Patient Record created: " + test2); System.out.println("It has hash code " + test2.hashCode()); } catch (BadVisitDateException e) { System.out.println("Creation failed " + e); } try { test2 = new PatientRecord(101, 17, 17, 2006, "high fever", "antibiotics"); System.out.println("Patient Record created: " + test2); System.out.println("It has hash code " + test2.hashCode()); } catch (BadVisitDateException e) { System.out.println("Creation failed " + e); } try { test2 = new PatientRecord(101, 12, 92, 2006, "high fever", "antibiotics"); System.out.println("Patient Record created: " + test2); System.out.println("It has hash code " + test2.hashCode()); } catch (BadVisitDateException e) { System.out.println("Creation failed " + e); } try { test2 = new PatientRecord(101, 12, 17, 06, "high fever", "antibiotics"); System.out.println("Patient Record created: " + test2); System.out.println("It has hash code " + test2.hashCode()); } catch (BadVisitDateException e) { System.out.println("Creation failed " + e); } } } File 3: PatientRecord
public class PatientRecord { private int id; private String date; private String reasonForVisit; private String treatmentPrescribed; public PatientRecord(int anId, int month, int day, int year, String reason, String treatment) } /** * Returns the patient's ID number. */ public int getPatientID() { } /** * Returns the patient's visit date. */ public String getVisitDate() { } /** * Returns the patient's reason for visiting. */ public String getReasonForVisit() { } /** * Returns the patient's prescribed treatment. */ public String getTreatmentPrescribed() { } public int hashCode() { } public boolean equals(Object other) { } public String toString() { } } Output . CSC220 (run) | Notifications | run: Patient Record created: Patient:101 [12/15/2006] Complaint: cough Prescribed: bed rest It has hash code 2115279812 Patient Record created: Patient : 101 [12/17/2006] Complaint : high fever Prescribed : antibiotics It has hash code 1455917371 Creation failed asmt04PatientRecord.BadVisitDateException: Month not in range 1-12 Creation failed asmt04PatientRecord.BadvisitDateException: Day not in range 1-31 Creation failed asmt04PatientRecord.BadVisitDateException: Year not greater than 1900 BUILD SUCCESSFUL (total time: 0 seconds)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
