Skip to content
Snippets Groups Projects
Commit bafad8b7 authored by Goik Martin's avatar Goik Martin
Browse files

Alternate switch based solution

parent 497b6be7
No related branches found
No related tags found
No related merge requests found
......@@ -53,11 +53,23 @@ public enum _3_BmiCategory {
* @return A category's successor or <code>null</code> if starting from {@link #VERY_SEVERELY_OBESE}.
*/
public _3_BmiCategory getFollowingCategory() {
if (ordinal() < VERY_SEVERELY_OBESE.ordinal()) {
return values()[ordinal() + 1];
} else {
return null;
switch (this) {
case UNDERWEIGHT: return NORMALWEIGHT;
case NORMALWEIGHT: return OVERWEIGHT;
case OVERWEIGHT: return MODERATELY_OBESE;
case MODERATELY_OBESE: return SEVERELY_OBESE;
case SEVERELY_OBESE: return VERY_SEVERELY_OBESE;
default: return null;
}
// Using ordinal() instead:
// if (ordinal() < VERY_SEVERELY_OBESE.ordinal()) {
// return values()[ordinal() + 1];
// } else {
// return null;
// }
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment