I am stuck in a simple thing. I have an array of gates called tags. It is important for me to have access to each element of the array using boolean:
public boolean energetic, calming, happy, sad;
public boolean[] trackTags = {energetic, calming, happy, sad};
I pass and assign booleans to the trackTags array (say [true, true, true, false]. Therefore, when I call trackTags [0], I get “true”. However, when I type “energetic”, which should be the same like trackTags [0], the value is always false. I know that booleans initializes false, but when I switch some values to the trackTags array for true, should the named elements also not change?
Second question: what is a good way for me to interact with boolean variable names? In particular, if I pass the string [] [happy, sad], and then I want to switch only the boolean [] values corresponding to the names in my String array, is this possible? I have no problem with the loop of elements in both arrays, but I obviously cannot compare the string to a boolean.
In general, is there a better way to interact with logical names? I am really confused by this.
source
share