So I am working on a ModelViewController tic-tac-toe game homework and I am trying to check that if the board is empty at position xpos, ypos or not, but I got an error that says
operator && cannot be applied to boolean,char
Why does this occur and how can I change it to make it work?
double xpos,ypos,xr,yr;
char[][] position = {{' ',' ',' '},
{' ',' ',' '},
{' ',' ',' '}};
public boolean isEmpty(int xpos, int ypos){
int pos=xpos+3*ypos;
boolean isPosWithinRange = pos>=0 && pos<9 ;
return isPosWithinRange && position[xpos][ypos]=' ';
}
correct your code, to use == for comparison