What I am trying to do
- I have an enum with 3 parts : LIQUID POWDER and UNKNOWN
- need to print this out as : Liquid or Powder
- not printing anything if its unknown
What I have tried
-make a String var type and set it to null
-I made an if-else chain that checks what enum value that the obj has and changes the comp of String type.
-and a boolean that allows printing if it's not UNKNOWN
- for some reason, i am just getting a blank
is there a simpler way of converting the enum values to lowercase strings?
what is wrong in what i am doing?
my code
the enum class
public enum FoundationType
{
LIQUID,
POWDER,
UNKNOWN
}
my method for printing
public String toString(){
String type = null;
boolean isUnknown = false;
if (thisType == FoundationType.POWDER ){type = "Powder";}
else if(thisType == FoundationType.LIQUID ){type = "Liquid";}
else if(thisType == FoundationType.UNKNOWN ){isUnknown = true;}
String output = null;
if(isUnknown){output = "Foundation" + System.lineSeparator() +
"Inventory ID :"+get_UniqueProductID()+""+ System.lineSeparator();
}else{
output = "Foundation" + System.lineSeparator() + "Base Is " +type+ "" + System.lineSeparator() +
"Inventory ID :"+get_UniqueProductID()+""+ System.lineSeparator()
+ System.lineSeparator()+ System.lineSeparator();
}
return output;
}