This document appears to be instructions for a hands-on activity on building a blood bank program in Java. It includes code for a BloodData class that stores blood type and Rh factor attributes, with getters and setters. The main method then prompts the user to input a blood type and Rh factor, creates a new BloodData object with those values, and prints a message confirming the addition to the blood bank.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
595 views2 pages
SALVADOR - 05 Hands On Activity 1 ARG
This document appears to be instructions for a hands-on activity on building a blood bank program in Java. It includes code for a BloodData class that stores blood type and Rh factor attributes, with getters and setters. The main method then prompts the user to input a blood type and Rh factor, creates a new BloodData object with those values, and prints a message confirming the addition to the blood bank.
return bloodType; } public String getRhFactor(){ return rhFactor; } public void setBloodType(String bloodType){ this.bloodType = bloodType; } public void setRhFactor(String rhFactor){ this.rhFactor = rhFactor; }
public void BloodData(String bt, String rh){
this.bloodType = bt; this.rhFactor = rh; System.out.println(bt+rh +" is added to the blood bank."); } }
public class RunBloodData05 {
public static void main(String[] args){ BloodData bds = new BloodData(); bds.setBloodType("O"); bds.setRhFactor("+"); System.out.println("Enter blood type of patient:"); System.out.println("Enter the Rhesus factor (+ or -):"); System.out.println(bds.getBloodType()+bds.getRhFactor()+" is added to the blood bank."); System.out.println("");
BloodData bd = new BloodData();
Scanner input = new Scanner(System.in); System.out.print("Enter blood type of patient: "); String bt = input.nextLine(); System.out.print("Enter the Rhesus factor (+ or -):"); String rh = input.nextLine(); bd.BloodData(bt, rh); } }