subject

Part A: Open the file BloodData. java 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 β€œO” and β€œ+”, and an overloaded constructor that requires values for both fields. Include get and set methods for each field. Open the file TestBloodData. java and click the Run button to demonstrate that each method works correctly.

Part B:
Open the file Patient. java which includes an ID number, age, and BloodData. Provide a default constructor that sets the ID number to β€œ0”, the age to 0, and the BloodData to β€œO” and β€œ+”. Create an overloaded constructor that provides values for each field. Also provide get methods for each field. Open TestPatient. java. Click the Run button at the bottom of your screen to demonstrate that each method works correctly.
Has to fit the below template
BloodData. java
public class BloodData
{
// declare private variables here
public BloodData()
{
// add default constructor values here
}
public BloodData(String bType, String rh)
{
// add constructor logic here
}
public void setBloodType(String bType)
{
// add method code here
}
public String getBloodType()
{
// add method code here
}
public void setRhFactor(String rh)
{
// add method code here
}
public String getRhFactor()
{
// add method code here
}
}
Patient. java
public class Patient
{
// declare private variables here
public Patient()
{
// add default constructor values here
}
public Patient(String id, int age, String bType, String rhFactor)
{
// add constructor logic here
}
public String getId()
{
// write method code here
}
public void setId(String id)
{
// write method code here
}
public int getAge()
{
// write method code here
}
public void setAge(int age)
{
// write method code here
}
public BloodData getBloodData()
{
// write method code here
}
public void setBloodData(BloodData b)
{
// write method code here
}
}
TestBloodData. java
public class TestBloodData
{
public static void main(String[] args)
{
BloodData b1 = new BloodData();
BloodData b2 = new BloodData("A", "-");
display(b1);
display(b2);
b1.setBloodType("AB");
b1.setRhFactor("-");
display(b1);
}
public static void display(BloodData b)
{
System. out. println("The blood is type " + b. getBloodType() + b. getRhFactor());
}
}
TestPatient. java
public class TestPatient
{
public static void main(String[] args)
{
Patient p1 = new Patient();
Patient p2 = new Patient("1234", 35, "B", "+");
BloodData b2 = new BloodData("A", "-");
display(p1);
display(p2);
p1.setId("3456");
p1.setAge(42);
BloodData b = new BloodData("AB", "-");
p1.setBloodData(b);
display(p1);
}
public static void display(Patient p)
{
BloodData bt = p. getBloodData();
System. out. println("Patient #" + p. getId() + " age: " + + p. getAge() +
"\n The blood is type " + bt. getBloodType() + bt. getRhFactor());
}

}
Thanks for the help, I can figure out how to do it, but not how to get it to fit into the template.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 21:00
In this lab, you add a loop and the statements that make up the loop body to a c++ program that is provided. when completed, the program should calculate two totals: the number of left-handed people and the number of right-handed people in your class. your loop should execute until the user enters the character x instead of l for left-handed or r for right-handed. the inputs for this program are as follows: r, r, r, l, l, l, r, l, r, r, l, x variables have been declared for you, and the input and output statements have been written.
Answers: 3
question
Computers and Technology, 22.06.2019 15:30
Which of the following examples has four beats in each measure?
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
Need asap assignment directions: think of an organization (business, religious institution, volunteer organization, sports team) with which you have been involved. imagine outfitting it with an it infrastructure. prepare a plan for what you would do to support outfitting it. draw a map of a network connecting all the individuals, give them pcs and printers, and lay out the design as best you can. the purpose is to begin working with these concepts, not to build a perfect network.
Answers: 2
question
Computers and Technology, 23.06.2019 19:00
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words.size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words.size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
You know the right answer?
Part A: Open the file BloodData. java that includes fields that hold a blood type (the four blood t...
Questions
question
Social Studies, 05.02.2020 00:00
question
Mathematics, 05.02.2020 00:00
question
Spanish, 05.02.2020 00:00