** Implement an instance method called redFlags. This method should return a boo
ID: 3765786 • Letter: #
Question
** Implement an instance method called redFlags. This method should return a boolean value. The method will return true if either the heart rate is less than 60 or greater than 100 OR if the body-temp is either less than 97.3 or greater than 99.1 .
** Implement a toString method that will build a String of all the data- fields of the EMR class. How can i do this part by not printing it out.
public class EMR {
private String name;
private String dob;
private String reasonForVisit;
private double bodyTemp;
private double heartRate;
private String diagnosis;
private String prescribedMedicine;
public static int patientCounter = 0;
// default constructor with no arguments
// increments static variable patientCounter
EMR() {
patientCounter++;
}
// the patient counter static variable.
EMR(String name, String dob) {
this.name = name;
this.dob = dob;
patientCounter++;
}
// data-fields. Also, increment the patient counter static variable.
public EMR(String name, String dob, String reasonForVisit, double bodyTemp, double heartRate, String diagnosis,
String prescribedMedicine) {
super();
this.name = name;
this.dob = dob;
this.reasonForVisit = reasonForVisit;
this.bodyTemp = bodyTemp;
this.heartRate = heartRate;
this.diagnosis = diagnosis;
this.prescribedMedicine = prescribedMedicine;
patientCounter++;
}
// set and get methods for name of the patient
void setName(String name) {
this.name = name;
}
String getName() {
return this.name;
}
// set and get methods for date of birth of the patient
public String getDob() {
return dob;
}
public void setDob(String dob) {
this.dob = dob;
}
// set and get methods for reason for visit of the patient
void setReasonForVisit(String reason) {
this.reasonForVisit = reason;
}
String getReasonForVisit() {
return this.reasonForVisit;
}
// set and get methods for body temperature of the patient
void setBodyTemp(double Temp) {
this.bodyTemp = Temp;
}
double getBodyTemp() {
return this.bodyTemp;
}
// set and get methods for heart rate of the patient
void setHeartRate(double heartRate) {
this.heartRate = heartRate;
}
double getHeartRate() {
return this.heartRate;
}
// set and get methods for diagnosis of the patient
void setDiagnosis(String diagnosis) {
this.diagnosis = diagnosis;
}
String getDiagnosis() {
return this.diagnosis;
}
// set and get methods for prescribed medicine of the patient
void setPrescribedMedicine(String medicine) {
this.prescribedMedicine = medicine;
}
// keeps tracks of how many patient objects are created.
public static int getPatientCounter() {
return patientCounter;
}
String getPrescribedMedicine() {
return this.prescribedMedicine;
}
// Main function which creates 3 patients A, B and C and
public static void main(String args[]) {
// print initial value of the patientCounter
// Since it is static variable, it can be used with out using any object
System.out.println("Initial patientCounter value is " + patientCounter);
// create an Object A and print patientCounter value
EMR A = new EMR();
System.out.println("patientCounter value of patient A is " + A.patientCounter);
// create an Object B and print patientCounter value
EMR B = new EMR();
System.out.println("patientCounter value of patient B is " + B.patientCounter);
// create an Object C and print patientCounter value
EMR C = new EMR();
System.out.println("patientCounter value of patient C is " + C.patientCounter);
}
}
Explanation / Answer
package studenthealthservices;
public class Studenthealthservices
{
public static void main(String[] args)
{
EMR p1 = new EMR("Colin", "10-22-74", "Strained Ankle", 99, 110, "hurt during football", "ankle brace");
System.out.println(p1.toString());
EMR p2 = new EMR("Anquan", "9-30-77", "stomach ache", 98, 120, "stress", "Tylenol");
System.out.println(p2.toString());
EMR p3 = new EMR("Buster", "3-27-1987", "Broken ankle", 99, 113, "Scott Cousins", "None");
System.out.println(p3.toString());
EMR P4 = new EMR("Frank The Tank", "4/1/89");
EMR p5 = new EMR("Merton Hanks", "03-12-1968");
}
}
public class EMR
{
private String name;
private String dob;
private String rfv;
private double bodyt;
private double hr;
private String diag;
private String pmeds;
public void setName(String name)
{
this.name = name;
}
public EMR(String name, String dob)
{
this.name = name;
this.dob = dob;
}
public String getName()
{
return name;
}
public EMR(String name, String dob, String rfv, double bodyt, double hr, String diag, String pmeds)
{
this.name = name;
this.dob = dob;
this.rfv = rfv;
this.bodyt = bodyt;
this.hr = hr;
this.diag = diag;
this.pmeds = pmeds;
}
public String getDob()
{
return dob;
}
public void setDob(String dob)
{
this.dob = dob;
}
public String getRfv()
{
return rfv;
}
public void setRfv(String rfv)
{
this.rfv = rfv;
}
public double getBodyt()
{
return bodyt;
}
public void setBodyt(double bodyt)
{
this.bodyt = bodyt;
}
public double getHr()
{
return hr;
}
public void setHr(double hr)
{
this.hr = hr;
}
public String getDiag()
{
return diag;
}
public void setDiag(String diag)
{
this.diag = diag;
}
public String getPmeds()
{
return pmeds;
}
public void setPmeds(String pmeds)
{
this.pmeds = pmeds;
}
public void redFlags()
{
String help = "get help!";
if (bodyt >= 97.3 && bodyt <= 99.1)
this.bodyt = bodyt;
if (hr >= 60 && hr <= 100)
this.hr = hr;
else
{
System.out.printf(help);
}
}
@Override
public String toString()
{
return " name : " + this.name
+ " Date of Birth: " + this.dob
+ " Reason for visit: " + this.rfv
+ " Body Temperature: " + this.bodyt
+ " Heart Rate " + this.hr
+ " Diagnosis: " + this.diag
+ " Prescribed Meds " + this.pmeds;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.