This is not scalable, what is the correct way to go about checking to see if the boolean method in all instances are false, rather than && each instance?
for (Button b : buttons) {
b.render();
if (b.isHovering()) {
cursor(HAND);
} else if (!buttons[0].isHovering() && !buttons[1].isHovering() && !buttons[2].isHovering() && !buttons[3].isHovering()) { //there has got to be a shorthand way of doing this, i am just unaware of how
cursor(ARROW);
}
}
// Check for True False in an array
// v1.0.0
// GLV 2020-MM-DD
boolean [] test;
boolean state = false;
int count = 0;
void setup()
{
size(200, 200);
//create a test array that is all true
test = new boolean [100];
for (int i = 0; i<100; i++)
{
test[i] = true;
}
// randomly assign a false to one element of test array
test[int(random(0, 100))] = false;
//check for false element in test and set state and return
//for(boolean j: test)
// {
// println(j, count);
// if (!j)
// {
// state = true;
// break; //exits when false
// }
// else
// state = false;
// count++;
// }
//Replaces above
println(checkState(test), count);
}
void draw()
{
background(0);
}
//returns true if it finds a false
boolean checkState(boolean [] arr)
{
for(boolean j:arr)
{
println(j, count);
if (!j)
{
state = true;
break;
}
else
state = false;
count++;
}
return state;
}