Why is it not saying I won?
Posted
by
Itachi
on Stack Overflow
See other posts from Stack Overflow
or by Itachi
Published on 2012-11-08T04:50:39Z
Indexed on
2012/11/08
5:01 UTC
Read the original article
Hit count: 226
This is my if statement... The buttons show up like this:
This is my if statement
if((buttons[3].getName()=="x" && buttons[6].getName()=="x" &&
buttons[9].getText()=="x")||(buttons[2].getName()=="x" &&
buttons[5].getName()=="x" && buttons[8].getName()=="x")||
((buttons[1].getName()=="x") && (buttons[4].getName()=="x") &&
(buttons[7].getName()=="x"))){
JOptionPane.showMessageDialog(null,"X Wins");
}
So if I select the 1st, 4th and 7th buttons (the left most 3 buttons) why does it not say "X Wins"?
As a sidenote, yes the buttons should have the name "x"
© Stack Overflow or respective owner