Skip to content

Commit

Permalink
Doing case insensitive comparison of units
Browse files Browse the repository at this point in the history
  • Loading branch information
dkayiwa committed Sep 11, 2020
1 parent 8ad37b6 commit d2a8db8
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,19 @@ public ModelAndView handleRequest(HttpServletRequest request, HttpServletRespons
if (latestWeight != null && latestHeight != null) {
double weightInKg;
double heightInM;
if (weightConcept.getUnits().equals("kg")) {
if (weightConcept.getUnits().equalsIgnoreCase("kg")) {
weightInKg = latestWeight.getValueNumeric();
} else if (weightConcept.getUnits().equals("lb")) {
} else if (weightConcept.getUnits().equalsIgnoreCase("lb")) {
weightInKg = latestWeight.getValueNumeric() * 0.45359237;
} else {
throw new IllegalArgumentException("Can't handle units of weight concept: "
+ weightConcept.getUnits());
}
if (heightConcept.getUnits().equals("cm")) {
if (heightConcept.getUnits().equalsIgnoreCase("cm")) {
heightInM = latestHeight.getValueNumeric() / 100;
} else if (heightConcept.getUnits().equals("m")) {
} else if (heightConcept.getUnits().equalsIgnoreCase("m")) {
heightInM = latestHeight.getValueNumeric();
} else if (heightConcept.getUnits().equals("in")) {
} else if (heightConcept.getUnits().equalsIgnoreCase("in")) {
heightInM = latestHeight.getValueNumeric() * 0.0254;
} else {
throw new IllegalArgumentException("Can't handle units of height concept: "
Expand Down

0 comments on commit d2a8db8

Please sign in to comment.