So, the problem is: 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 O and +, and an overloaded constructor that requires values for both fields. Include get and set methods for each field. Create a class named Patient that 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 values to O and +. Create an overloaded constructor that provides values for each field. Also provide get methods for each field.The exisitng code is - public class BloodData {     private String bloodType;     private String rhFactor;     public BloodData() {     }     public BloodData(String bType, String rh) {     }     public void setBloodType(String bType) {     }     public String getBloodType() {     }     public void setRhFactor(String rh) {     }     public String getRhFactor() {     } } public class Patient {     private String id;     private int age;     private BloodData bloodData;     public Patient() {     }     public Patient(String id, int age, String bType, String rhFactor) {     }     public String getId() {     }     public void setId(String id) {     }     public int getAge() {     }     public void setAge(int age) {     }     public BloodData getBloodData() {     }     public void setBloodData(BloodData b) {     } }   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());     } }   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());     } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

So, the problem is:

  1. Create a class named BloodData that includes fields that hold a blood type (the four blood types are OAB, 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.

  2. Create a class named Patient that 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 values to O and +. Create an overloaded constructor that provides values for each field. Also provide get methods for each field.The exisitng code is -

    public class BloodData {
        private String bloodType;
        private String rhFactor;
        public BloodData() {
        }
        public BloodData(String bType, String rh) {
        }
        public void setBloodType(String bType) {
        }
        public String getBloodType() {
        }
        public void setRhFactor(String rh) {
        }
        public String getRhFactor() {
        }
    }
    public class Patient {
        private String id;
        private int age;
        private BloodData bloodData;
        public Patient() {
        }
        public Patient(String id, int age, String bType, String rhFactor) {
        }
        public String getId() {
        }
        public void setId(String id) {
        }
        public int getAge() {
        }
        public void setAge(int age) {
        }
        public BloodData getBloodData() {
        }
        public void setBloodData(BloodData b) {
        }
    }
     
    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());
        }

    }
     
    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());
        }

    }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY