Question: File 1 /** * DO NOT CHANGE * * Visit record could not be created * when the date information was invalid. */ public class

File 1 /** * DO NOT CHANGE * * Visit record couldFile 1

/**

* 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

/**

*

* 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

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() {

}

}

PART 3-Dictionaries and Hashing, 12 points 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 program's output must be identical to the output of the sample run: Output-CSC220 (run) | Notifications un: | 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: antibioticis 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 SUCCESSEUL (total time: 0 seconds)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!