Checking the Winner on Tic Tac Toe game on Windows Form Application - C++ -
i'm making tic-tac-toe game windows form application c++ class , need on making function find winner. in void winner function, i'm checking see if 3 squares match i'm not sure if condition in if statement right. program worked when added void winner function, didn't work. in advance.
private: system::void a1_click(system::object^ sender, system::eventargs^ e) { bool turn = true; if (turn) a1->text = "x"; else a1->text = "o"; turn = !turn; winner(); } void winner() { if (a1 = a2 && a2 == a3) label1-> text= "winner"; }
in statement inside if(), have missed equal sign, might causing problem. assigning a1
a2
. try this,
if (a1==a2 && a2==a3)
also, think must trying compare text
attribute of a1, a2 , a3. purpose use,
if(a1->text==a2->text && a2->text==a3->text)
Comments
Post a Comment