I have a class with a mix of booleans and integers:
class Soup {
boolean mItem1 = false
boolean mItem2 = false
int mItem3 = 10
boolean mItem4 = false
int mItem5 = 100
{
I also have a method "void addIngredient(String itemName)" that I will pass a string value like "Item1" or "Item4".
void addIngredient(String itemName) {
// I need help with the following line
Soup.m(itemName) = true
}
How can I set the value of variable Soup.mItem1 for example, WITHOUT using an if statement or switch. For example I might add up to 25 or 50 "mItems" variables that may either be a boolean or integer value.
I basically want to take Soup.m and concatenate the string I pass (Item1 for example) to make the string "Soup.mItem1" and then set a value, such has "Soup.mItem1 = true" or "Soup.nItem3 = 1000".