Question
Need help with the following assignment in JAVA. I will provide my Patient i have but i need help changing into enum classes as shown.
Need help with the following assignment in JAVA. I will provide my Patient i have but i need help changing into enum classes as shown. PLEASE USE THE MAIN CLASS SHOWN ON THE PICTURE TO TEST THE ASSIGNMENT.
my class I need help editing
class Patient {
private int id;
private int age;
BloodData bd;
public Patient() {
id = 0;
age = 0;
bd = new BloodData("O", '+');
}
public Patient(int aId, int aAge, char aRhFactor, String aBlood_type) {
super();
id = aId;
age = aAge;
bd = new BloodData(aBlood_type, aRhFactor);
}
public int getId() {
return id;
}
public void setId(int aId) {
id = aId;
}
public int getAge() {
return age;
}
public void setAge(int aAge) {
age = aAge;
}
public BloodData getBd() {
return bd;
}
public void setBd(BloodData aBd) {
bd = aBd;
}
class BloodData {
String blood_type;
char rhFactor;
public BloodData(String aBlood_type, char aRhFactor) {
super();
blood_type = aBlood_type;
rhFactor = aRhFactor;
}
public BloodData(String aBlood_type) {
super();
blood_type = aBlood_type;
rhFactor = '+';
}
public BloodData(char aRhFactor) {
super();
blood_type = "O";
rhFactor = aRhFactor;
}
}
// displays blood data
public void displayBlood() {
System.out.println("Blood type : " + bd.blood_type + bd.rhFactor);
}
}
Enumeration Lab 07 - Patient Info. Part 2 Refactor your BloodData Class to utilize enums for blood_type (O, A, B, or AB) and RhFactor(+, -), instead of Strings and chars. You may have to make additional changes elsewhere in your patient class. Note:+'and -'are illegal identifiers. You must use an enum constructor to hold char data. Simple Main Your main must only contain the following lines of code and execute with the expected output. Patient Timmy-new Patient); System.out,printin("Patient ID: "+ Timmy.getiDO+ Timmy.displayBlood0 Patient Spike = new Patient(1337, 19. RhFactor.NEGATIVE. BloodType.AB) nPatient Age:"+ Timmy.getAge0): System.out.printin("Patient ID:"+ Spike.getiDO + nPatient Age: "+ Spike.getAge)); Spike.displayBlood) Expected Output: Patient ID: 0 Patient Age: 0 Blood Type: O+ Patient ID: 1337 Patient Age: 19 Blood Type: ABStep 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