package lectures.types.enums;
import util.annotations.StructurePattern;
import util.annotations.StructurePatternNames;
@StructurePattern(StructurePatternNames.BEAN_PATTERN)
@util.annotations.Explanation("Stores previously computed BMI value in a variable")
@util.annotations.WebDocuments({"4_State_Notes.pdf",
"p69-dewan.pdf"
})
public class ABMISpreadsheetWithIntConstants implements BMISpreadsheetWithIntConstants {
double height, weight;
double initialHeight, initialWeight;
public ABMISpreadsheetWithIntConstants(double theInitialHeight, double theInitialWeight) {
height = theInitialHeight;
weight = theInitialWeight;
initialHeight = theInitialHeight;
initialWeight = theInitialWeight;
}
public ABMISpreadsheetWithIntConstants() {}
public double getHeight() {return height;}
public void setHeight(double newValue) {height = newValue;}
public double getWeight() {return weight;}
public void setWeight(double newValue) {weight = newValue;}
public double getBMI() {return weight/(height*height);}
int race = IntRace.AFRICAN_AMERICAN;
public int getRace() {
return race;
}
public void setRace (int newVal) {
race = newVal;
}
public int getBMIClassification() {
double bmi = getBMI();
if (bmi <= MAX_UNDERWEIGHT_BMI)
return IntBMIClassification.UNDER_WEIGHT;
else if (bmi <= MAX_NORMAL_BMI)
return IntBMIClassification.NORMAL;
else if (bmi <= MAX_OVERWEIGHT_BMI)
return IntBMIClassification.OVER_WEIGHT;
else if (bmi <= MAX_OBESE_BMI)
return IntBMIClassification.OBESE;
else
return IntBMIClassification.EXTREMELY_OBESE;
}
public static void main (String[] args) {
try {
bus.uigen.ObjectEditor.edit(new ABMISpreadsheetWithIntConstants(1.77, 75));
} catch (Exception e) {
e.printStackTrace();
}
}
}