检查在井字游戏的赢家? [英] Checking for winner in TicTacToe?

查看:122
本文介绍了检查在井字游戏的赢家?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是看到(在2玩家)游戏井字谁赢得的最好方法?现在,我使用类似于下面的内容:

What would be the best way to see (in a 2 player) game of Tic Tac Toe who won? Right now I'm using something similar to the following:

if (btnOne.Text == "X" && btnTwo.Text == "X" && btnThree.Text == "X")
{
    MessageBox.Show("X has won!", "X won!");
    return;
}
else
// I'm not going to write the rest but it's really just a bunch
// if statements.



那么,如何摆脱多条if的?

So how do I get rid of the multiple if's?

推荐答案

东西alongs:

rowSum == 3 || columnSum == 3 || diagnolSum == 3

..

这篇关于检查在井字游戏的赢家?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆