Java Programming (MindTap Course List)
Java Programming (MindTap Course List)
9th Edition
ISBN: 9781337397070
Author: Joyce Farrell
Publisher: Cengage Learning
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 4, Problem 4PE
Program Plan Intro

a.

Display the blood group and Rh factor

Program plan:

Filename: “BloodData.java”

  • Define the “BloodData” class.
    • Declare the required variables.
    • Define of constructor
      • Set the default values
    • Define the parameterized constructor.
      • Set the values.
    • Define “getRhFact” method
      • Return the Rh factor
    • Define “setRhFact” method
      • Set the Rh factor value.
    • Define “getBloodType” method
      • Return the blood type.
    • Define “setBloodType” method
      • Set the blood type value.

Filename: “TestBloodData.java”

  • Define the “TestBloodData” class.
    • Define the main method.
      • Create an object for “BloodData” class.
      • Display the blood group and Rh factor.
      • Set the blood group and Rh factor.
      • After setting the blood group and Rh factor display the blood group and Rh factor.
      • Create an object for “BloodData” class.
      • Display the new blood group and Rh factor.

Program Plan Intro

b.

Display the patient id and age

Program plan:

Filename: “BloodData.java”

  • Define the “BloodData” class.
    • Declare the required variables.
    • Define of constructor
      • Set the default values
    • Define the parameterized constructor.
      • Set the values.
    • Define “getRhFact” method
      • Return the Rh factor
    • Define “setRhFact” method
      • Set the Rh factor value.
    • Define “getBloodType” method
      • Return the blood type.
    • Define “setBloodType” method
      • Set the blood type value.

Filename: “Patient.java”

  • Define the “Patient” class.
    • Declare the required variables.
    • Define of constructor
      • Set the default values
    • Define the parameterized constructor.
      • Set the values.
    • Define “getIdNumber” method
      • Return the patient id number.
    • Define “setIdNumber” method
      • Set the patient id number.
    • Define “getAge” method
      • Return the age.
    • Define “setAge” method
      • Set the age.
    • Define “getBd” method
      • Return the blood type.
    • Define “setBd” method
      • Set the blood type value.

Filename: “TestPatient.java”

  • Define the “TestBloodData” class.
    • Define the main method.
      • Create an object for “Patient” class.
      • Display the patient id number and age.
      • Set the patient id number and age.
      • After setting the patient id number and age display patient id number and age.
      • Create an object for “Patient” class.
      • Display the new patient id number and age

Blurred answer
Students have asked these similar questions
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. Save this file as BloodData.java. Create an application named TestBlood Data that demonstrates each method works correctly. Save the application as TestBloodData.java.
Create a class named BloodData that includes fields that hold a blood type (the four blood types are O, A, B, and AB) and a 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 id, age, and bloodData fields. 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 TestBloodData.java and TestPatient.java files have been provided to test your implementation of each class. Code is in java.
a - Create a FitnessTracker class that includes data fields for a fitness activity, the number of minutes spent participating, and the date. The class includes methods to get each field. In addition, create a default constructor that automatically sets the activity to running, the minutes to 0, and the date to January 1 of the current year. Save the file as FitnessTracker.java. Create an application that demonstrates each method works correctly, and save it as TestFitnessTracker.java. b - Create an additional overloaded constructor for the FitnessTracker class you created in Exercise 3a. This constructor receives parameters for each of the data fields and assigns them appropriately. Add any needed statements to the TestFitnessTracker application to ensure that the overloaded constructor works correctly, save it, and then test it. c - Modify the FitnessTracker class so that the default constructor calls the three-parameter constructor. Save the class as FitnessTracker2.java. Create an…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Introduction to Classes and Objects - Part 1 (Data Structures & Algorithms #3); Author: CS Dojo;https://www.youtube.com/watch?v=8yjkWGRlUmY;License: Standard YouTube License, CC-BY