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
public class Patient {
private int ID_number,age;
private BloodData blood;
//default constructor
public Patient() {
this.ID_number = 0;
this.age = 0;
this.blood = new BloodData("O",'+');
}
//overloading constructor for setting values
public Patient(int ID_number,int age,BloodData blood){
this.ID_number = ID_number;
this.age = age;
this.blood = blood;
}
//Getters and Setters
public void setId(int ID_number){
this.ID_number = ID_number;
}
public int getId(){
return this.ID_number;
}
public void setAge(int age){
this.age = age;
}
public int getAge(){
return this.age;
}
public void setBlood(BloodData blood){
this.blood = blood;
}
public BloodData getBlood(){
return this.blood;
}
private class BloodData {
//Defining the private variables
private String bloodType;
private char rhFactor;
//default constructor
public BloodData() {
this.bloodType = "O";
this.rhFactor = '+';
}
//overloading constructors
public BloodData(String bloodType ,char rhFactor) {
this.bloodType= bloodType;
this.rhFactor = rhFactor;
}
//Getters and setters
public void setBloodType(String bloodType){
this.bloodType = bloodType;
}
public String getBloodType() {
return this.bloodType;
}
public void setRhFactor(char rhFactor){
this.rhFactor = rhFactor;
}
public char getRhFactor() {
return this.rhFactor;
}
//toString method for printing the varaibles
public String toString(){
return this.bloodType + this.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: AB- 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