Here's a section of code from one of my classes:
public void run() {
SomeClass[][] someClassArray = new SomeClass[6][];
someClassArray[0] = new SomeClass[1];
someClassArray[1] = new SomeClass[4];
someClassArray[2] = new SomeClass[16];
someClassArray[3] = new SomeClass[64];
someClassArray[4] = new SomeClass[256];
someClassArray[5] = new SomeClass[1024];
someFunction(0,0);
}
someFunction(int i, int j) {
if(i == 5) {
someClassArray[i][j].flag = test(i,j); // BASE CASE
}
else {
if(someFunction(someClassArray(i+1,j*4))
&& someFunction(someClassArray(i+1,j*4+1))
&& someFunction(someClassArray(i+1,j*4+2))
&& someFunction(someClassArray(i+1,j*4+3)))
someClassArray[i][j].flag = true;
else
someClassArray[i][j].flag = false;
}
return someClassArray[i][j].flag;
}
class SomeClass {
boolean flag;
// other stuff
}
boolean test(int i, int j) {
// test some property of this coordinate
}
Essentially what I want is to set the flag of one SomeClass object to true only if the four corresponding objects' flags in the next array level are also true. Unfortunately, I seem to be having problems with this:
if(someFunction(someClassArray(i+1,j*4))
&& someFunction(someClassArray(i+1,j*4+1))
&& someFunction(someClassArray(i+1,j*4+2))
&& someFunction(someClassArray(i+1,j*4+3)))
It looks like it's only checking the first condition (I added in a counter so check how many times someFunction is called and it only went up to 6, rather than the 1365 I should be getting); are you not able to do multiple function calls in an if statement in Java? or am I doing it wrong?
(Sorry about the formatting by the way; this is my first time posting here)