我制作了一个井字游戏,并且正在制作另一个代码更少的版本。无论如何...这是我的代码...我在 do while 语句之间使用了一些代码,但是是的...
var rc = new Random();
do
{
storeRI = rc.Next(1, 9);
if (storeRI == 1 & button1.Text == "")
{
button1.Text = "O";
Turn = 1;
TestWin();
break;
}
else if (storeRI == 2 & button2.Text == "")
{
button2.Text = "O";
Turn = 1;
TestWin();
break;
}
} while (Turn == 2 & button1.Text == "" | button2.Text == "" | button3.Text == "" | button3.Text == "" | button4.Text == "" | button5.Text == "" | button6.Text == "" | button7.Text == "" | button8.Text == "" | button9.Text == "");
}
else
{
MessageBox.Show("It's a draw");
}
我主要想专注于这段代码......缩短...... :)
} while (Turn == 2 & button1.Text == "" | button2.Text == "" | button3.Text == "" | button3.Text == "" | button4.Text == "" | button5.Text == "" | button6.Text == "" | button7.Text == "" | button8.Text == "" | button9.Text == "");