Professional Documents
Culture Documents
Drueco_
Date: October 24, 2022_
Section: BT304 | BSIT_
Syntax
import java.util.*;
public BloodData(){
bloodType = "O";
rhFactor = "+";
}
public void setBloodType(String bloodType){
this.bloodType = bloodType;
}
public String getBloodType(){
return bloodType;
}
public void setRhFactor(String rhFactor){
this.rhFactor = rhFactor;
}
public String getRhFactor(){
return rhFactor;
}
public void display() {
}
}
// John Patrick Drueco | BT304 / BSIT
Outputs: `
Explanation
To sum up the first class, basically it just shows here the scanner or the
user needed to input and the if else statement which will display by the
user inputs.
In second class, the bloodType and rhFactor is private which is
this access modifier it can only be accessed within its own class.
Therefore, I use the setter and getter methods or the encapsulation
to able to call or access the method and lastly to be able to display
or print the method base on the user inputs, if the if condition this
class will program to print the default blood type and rhesus
factor.