Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives: Use Javadocs to document a class and methods Design a Java class Use fields (instance variables) Write multiple constructors Write accessor methods Write mutator

Objectives:

  • Use Javadocs to document a class and methods
  • Design a Java class
  • Use fields (instance variables)
  • Write multiple constructors
  • Write accessor methods
  • Write mutator methods
  • Use the this keyword
  • Use string concatenation
  • Round floating point numbers (using Math.round())
  • Write test cases
  • Use a Scanner object

Description

For this project, you get to design a Patient class that stores a patient's first name, height and weight as fields. Include both a constructor without any parameters and one with parameters for name (String), height (double) and weight (double) (in that order). Include appropriate accessor and mutator methods (and label them with comments including the terms "accessor" or "mutator"). Use the naming conventions of setValue() and getValue() (i.e., setName() and getName(), etc.). Appropriately, include the this keyword in your code. Additionally, include a method named toString() that returns a String formatted as in the examples below (including rounding to one decimal place). Include an updateBMI() method that calculates the Body Mass Index of the patient based on the following formula: BMI = 703 * weight_in_lbs / (height_in_inches * height_in_inches). Also include an accessor method named getBMI. Note: make sure that the BMI is correct before returning it. Write at least three test cases for the updateBMI() method in a main() method in the Patient class. Put each test case into a different method, named test1(), test2() and test3(). Document both the Patient class and its methods with comments and Javadoc comments.

Create a Main class that requests input from the user and populates a Patient object and calls it's toString() method.

Create a Main class that requests input from the user and populates a Patient object and calls it's toString() method.

Examples for the input and output part (user input in bold face blue):

Please enter the patient's first name: Donald You entered Donald Please enter the patient's height (in inches): 75 You entered 75.0 Please enter the patient's weight (in inches): 243.0 You entered 243.0 Patient: Donald is 75.0 inches tall and weighs 243.0 pounds (BMI: 30.4)
Please enter the patient's first name: Mary You entered Mary Please enter the patient's height (in inches): 68.0 You entered 68.0 Please enter the patient's weight (in inches): 165 You entered 165.0 Patient: Mary is 68.0 inches tall and weighs 165.0 pounds (BMI: 25.1)

and

Please enter the patient's first name: Liam You entered Liam Please enter the patient's height (in inches): 72.1 You entered 72.1 Please enter the patient's weight (in inches): 185 You entered 185.0 Patient: Liam is 72.1 inches tall and weighs 185.0 pounds (BMI: 25.0)

For right now in the testMutators_Accessors test, I have something like the following and I would like to keep the same names for each method to go along with the instructions for the code:

Patient person = new Patient( );

person.setName( randName );

person.setHeight( randHeight );

person.setWeight( randWeight );

double randBmi = 703 * randWeight / (randHeight * randHeight);

assertEquals( randHeight, person.getHeight(), 0.01 );

assertEquals( randWeight, person.getWeight(), 0.01 );

assertEquals( randBmi, person.getBMI(), 0.01 );

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

1. What are the critical elements of the communication process?

Answered: 1 week ago