Question: plz help answer Comparable Suppose you have a pre-existing class Dieter that models a person trying to monitor diet and weight to improve his/her Body
Comparable Suppose you have a pre-existing class Dieter that models a person trying to monitor diet and weight to improve his/her Body Mass Index (BMI) rating. The class has the following data and behavior: Field/Constructor/Method Description private String name the dieter's full name, such as "John Smith" private int height the dieter's height, in inches private int weight the dieter's weight, in pounds public Dieter(String name, int h, int w) makes a dieter with given name, height weight public String getName( returns the dieter's name public int getHeight returns the dieter's height public int getWeight returns the dieter's weight public double getBMIO computes the dieter's Body Mass Index (BMI). which is (weight/ beight2) 703 public void gain(int pounds) called when the dieter gains weight public void lose(int pounds) called when the dieter lose weight We want Dicter objects comparable to each other using the Comparable interface based on: Dieters are primarily compared by their BMI ratings, A dieter with a lower BMI is less than" one with a higher BMI If two dicters have the same BMI, the tie is broken by height, the shorter person is considered to be "less than the taller one If two dicters have the same BMI and height, the tie is broken by name. The dieter whose name comes first in alphabetical order is considered "less than the one whose name comes later in ABC order If the two dieters have the sathe BMI, height, and name, they are considered to be "equal." Being careful to use the correct case of letters, fill in the blank boxes with each portion of the comparable Dieter class header
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
