diff options
Diffstat (limited to 'src/Q7/Person.java')
| -rw-r--r-- | src/Q7/Person.java | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/src/Q7/Person.java b/src/Q7/Person.java index 0c4e32e..aaca8af 100644 --- a/src/Q7/Person.java +++ b/src/Q7/Person.java @@ -14,9 +14,15 @@ public class Person { private double bmi; private double height; private double weight; - private String category; private String name; + /** + * Create an instance of a person and calculates their BMI. + * + * @param name the name of the person + * @param weight the weight of the person + * @param height the height of the person + */ public Person(String name, double weight, double height) { this.name = name; this.weight = weight; @@ -24,10 +30,21 @@ public class Person { this.updateBMI(); } + /** + * Returns the category the person is categorized as based on BMI. + * + * @return A category of "Underweight", "Normal", "Overweight" or "Obese" + */ public String getCategory() { return this.getCategory(this.bmi); } + /** + * Returns the category for the BMI. + * + * @param bmi the BMI to determine a category for. + * @return A category of "Underweight", "Normal", "Overweight" or "Obese" + */ public String getCategory(double bmi) { if (bmi < 18.5) return "Underweight"; else if (bmi < 25.0) return "Normal"; @@ -35,41 +52,80 @@ public class Person { return "Obese"; } + /** + * Returns the persons name + * + * @return the persons name + */ public String getName() { return this.name; } + /** + * Returns the persons BMI + * + * @return the persons BMI + */ public double getBMI() { return this.bmi; } + /** + * Returns the persons height + * + * @return the persons height + */ public double getHeight() { return this.height; } + /** + * Returns the persons weight + * + * @return the persons weight + */ public double getWeight() { return this.weight; } - public void setBMI(double bmi) { + /** + * Change the BMI + * + * @param bmi the new BMI + */ + private void setBMI(double bmi) { this.bmi = bmi; } + /** + * Change the Height + * + * @param height the new height + */ public void setHeight(double height) { this.height = height; this.updateBMI(); } + /** + * Change the name + * + * @param name the new name + */ public void setName(String name) { this.name = name; } + /** + * Change the weight + * + * @param weight the new weight + */ public void setWeight(double weight) { this.weight = weight; this.updateBMI(); } - // BMI = (weight (lb) * 703) / ((height (in))^2) private void updateBMI() { this.setBMI((this.weight * 703) / Math.pow(height, 2)); } |
