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 ABMISpreadsheetWithStringConstants implements BMISpreadsheetWithStringConstants {
double height, weight;
double initialHeight, initialWeight;
public ABMISpreadsheetWithStringConstants(double theInitialHeight, double theInitialWeight) {
height = theInitialHeight;
weight = theInitialWeight;
initialHeight = theInitialHeight;
initialWeight = theInitialWeight;
}
public ABMISpreadsheetWithStringConstants() {}
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);}
String race = StringRace.AFRICAN_AMERICAN;
public String getRace() {
return race;
}
public void setRace (String newVal) {
race = newVal;
}
public String getBMIClassification() {
double bmi = getBMI();
if (bmi <= MAX_UNDERWEIGHT_BMI)
return StringBMIClassification.UNDER_WEIGHT;
else if (bmi <= MAX_NORMAL_BMI)
return StringBMIClassification.NORMAL;
else if (bmi <= MAX_OVERWEIGHT_BMI)
return StringBMIClassification.OVER_WEIGHT;
else if (bmi <= MAX_OBESE_BMI)
return StringBMIClassification.OBESE;
else
return StringBMIClassification.EXTREMELY_OBESE;
}
public static void main (String[] args) {
try {
bus.uigen.ObjectEditor.edit(new ABMISpreadsheetWithStringConstants(1.77, 75));
} catch (Exception e) {
e.printStackTrace();
}
}
}