Java operaton on boolean varibles
hello all i am finishing up a tic tac toe game but i have a question about Boolean vs int. my question is what do i do if i need to use symbols such as <>||=&& with boolean. here is a fragment of what i am working on to give you an idea of what im trying to do
Code :
public boolean checkValid()
{
boolean col;
boolean row;
if(row<0||row>2)
return true;
}
any help and suggestions are always appreciated
Re: question about boolean varibles
Boolean values can only hold true or false! So you cannot use<> operators, you can use the others though.
Chris
Re: question about boolean varibles
ok so how would i go about creating that method using boolen.
Re: question about boolean varibles
Describe in words what you want to achieve, because I can't make any sense of that code lol
Chris
Re: question about boolean varibles
ok this is what i am attempting to do. i need to add a method to check if a move is valid. for example if i put in 0,0 for x and the rperson playing o does the same thing i want to be able to tell them that move is invalid please pick again
Re: question about boolean varibles
You guys were up early this morning!!
You could do it like this big_c:
Code :
public class CheckMove {
public static int row;
public static boolean isValid;
public static void CheckMyMove() {
if (row < 0 || row > 2) {
isValid = true;
} else
isValid = false;
}
public static void main(String[] args) {
CheckMove cm = new CheckMove();
cm.CheckMyMove();
System.out.println(isValid);
}
}