Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class named BloodData that includes fields that hold a blood type (the

ID: 673838 • Letter: C

Question

Create a class named BloodData that includes fields that hold a blood type (the four blood types are O, A, B, and AB) and an Rh factor (the factors are + and -). Create a default constructor that sets the fields to "0" and "+", and an overloaded constructor that requires values for both fields. Include get and set methods for each field. Save this file as BloodData.java. Create an application names TestBloodData that demonstrates each method works correctly. Save the application as TestBloodData.java

Explanation / Answer

import java.util.Scanner;
public class Patient
{
public static void main(String[] args)
{
    String patient_ID;
    int patient_Age;
    String patient_Rh;
    String patient_Blood;
    Scanner input = new Scanner(System.in);
    System.out.print("what is the patients ID?");
    patient_ID=input.nextLine();
    Scanner input = new Scanner(System.in);
    System.out.print("what is the patients age?");
    patient_Age=input.nextInt();
    input.nextLine();
    Scanner input = new Scanner(System.in);
    System.out.print("what is the patients RH?");
    patient_Rh=input.nextLine();
    Scanner input = new Scanner(System.in);
    System.out.print("What is the patients blood type?");
    patient_Blood=input.nextLine();
    Patient newpatient = new Patient(blood,rh,id,age);
    System.out.println("The patients blood type is " +newpatient.getBlood()+". The patients RH is " +newpatient.getRh()+". The patients ID is " +newpatient.getID()+". The patients age is " +newpatient.getAge()+".");

}
}
class BloodData
{
private String blood;
private String rh;

   public BloodData()
   {
     blood="O";
     rh="+";
   }
   public BloodData(String proposedBlood, String proposedRh)
   {
   blood=proposedBlood;
   rh=proposedRh;
   }
   public String getblood()
   {
    return blood;
   }
   public String getrh()
   {
    return rh;
   }
   public void setblood(String proposedBlood)
   {
    blood=proposedBlood;
   }
    public void setRh(String proposedRh)
    {
    rh=proposedRh;
   }
}

class Patient
{
private String ID;
private int age;
private BloodData bloodData;

public Patient()
{
    bloodData = new BloodData(blood, rh);
    ID="0";
    age=0;
}
public Patient(String aBlood, String aRh, String aID, int aAge)
{
    age=aAge;
    ID=aID;
    blood=aBlood;
    rh=aRh;
}
public String getID()
   {
    return ID;
   }
public int getAge()
    {
    return age;
    }
public String getBlood()
    {
    return blood;
    }
public String getRh()
   {
    return rh;
   }
public void setID(String aID)
{
   ID=aID;
}
public void setAge(int aAge)
{
   age=aAge;
}
public void setBlood(String aBlood)
{
   blood=aBlood;
}
public void setRh(String aRh)
{
   rh=aRh;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote