These functions are giving me an error, asking for a semicolon, but when I add it, it doesn’t fix the error.
<>
int arrayTotal(int array[]) {
int total= 0;
for (int i= 0; i<array.length; i++) {
total+=array[i];
}
return total;
}
void setXandYCoords(Die dice[]) {
for (int i= 0; i<dice.length; i++) {
int x= (dice.length/2)-i;
x*=-1;
dice[i].setCoords(SCREEN_WIDTH+(x*(dice[i].getDieFace().width+(dice[i].getDieFace().width/2))),(SCREEN_HEIGHT/2)-(dice[i].getDieFace().height/2));
}
return null;
}
}
</>
When processing tells you that you have a missing semicolon where you clearly doesn’t, it generally means that you have something like a missing bracket.
In your case, you’re missing a ‘)’ in this line. I believe you should add it after the ~.getDieFace().width/2
I tried that, and it is still giving me an error. Also, for arrayTotal function, it is still giving me an error. Any thoughts?
int arrayTotal(int array[]) { int total= 0; for (int i= 0; i<array.length; i++) { total+=array[i]; } return total; }
I guess the error is somewhere else
please post entire code
int arrayTotal( int array[] ) {
int total= 0;
for (int i= 0; i<array.length; i++) {
total+=array[i];
}
return total;
}
In general:
You have a class Die
In this line, you are referring 3 times to the dice[i]. (apart from the initial one).
This calls for making the line a function (method) within the class:
void setCoordsForScreen() {
setCoords(
SCREEN_WIDTH+(x*(getDieFace().width+(getDieFace().width/2))),
(SCREEN_HEIGHT/2)-(getDieFace().height/2)
);
}