Question
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 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)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started