errr..juz to let u know how my design looks like
(these below are the names given to the buttons in case u are wondering)
btn11 btn12 btn13
btn21 btn22 btn23
btn31 btn32 btn33
btnPlayer1 btnPlayer2
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace tictactoe
{
public partial class TTT : Form
{
public TTT()
{
InitializeComponent();
}
private void btn22_Click(object sender, EventArgs e)
{
playGame(btn22);
}
private void btn11_Click(object sender, EventArgs e)
{
playGame(btn11);
}
private void btn12_Click(object sender, EventArgs e)
{
playGame(btn12);
}
private void btn13_Click(object sender, EventArgs e)
{
playGame(btn13);
}
private void btn21_Click(object sender, EventArgs e)
{
playGame(btn21);
}
private void btn23_Click(object sender, EventArgs e)
{
playGame(btn23);
}
private void btn31_Click(object sender, EventArgs e)
{
playGame(btn31);
}
private void btn32_Click(object sender, EventArgs e)
{
playGame(btn32);
}
private void btn33_Click(object sender, EventArgs e)
{
playGame(btn33);
}
private void btnPlayer1_Click(object sender, EventArgs e)
{
btnPlayer1.Enabled = false;
player1 = true;
player2 = false;
}
private void btnPlayer2_Click(object sender, EventArgs e)
{
btnPlayer2.Enabled = false;
player1 = false;
player2 = true;
}
private void TTT_Load(object sender, EventArgs e)
{
bool player1 = false, player2 = false;
string str11 = "0" , str12 = "0" , str13 "0"
str21 = "0" , str22 = "0" , str23 "0"; // for this case i duno wats wrong wif it.it juz shows there is an error...
str31 = "0" , str32 = "0" , str33 "0";
}
private void playGame
{
if (player1 = false && player2 = false)
MessageBox.Show("select Player1's turn, then click on 1 tic tac toe box",
"select Player no", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
int cellPlace = 0
if (player1) cellUpdate "cell"10+1;
else if (player2) cellUpdate "cell" 10+2;
if ((player1) && (btn.Text == "")
{
btn.Text = "1" ;
btnPlayer1.Enabled = false ;
btnPlayer2.Enabled = true ;
updateCell(cellUpdate);
winGame();
player1 = false ;
player2 = true;
}
else if
{
btn.Text = "2" ;
btnPlayer1.Enabled = true ;
btnPlayer2.Enabled = false ;
updateCell(cellUpdate);
winGame();
player1 = true;
player2 = false;
}
}
private void updateCell (int cell)
{
switch (cell)
{
case 111: str11 = "1" ; break;
case 112: str11 = "2" ; break;
case 121: str12 = "1" ; break;
case 122: str12 = "2" ; break;
case 131: str13 = "1" ; break;
case 132: str13 = "2" ; break;
case 211: str21 = "1" ; break;
case 212: str21 = "2" ; break;
case 221: str22 = "1" ; break;
case 222: str22 = "2" ; break;
case 231: str23 = "1" ; break;
case 232: str23 = "2" ; break;
case 311: str31 = "1" ; break;
case 312: str31 = "2" ; break;
case 321: str32 = "1" ; break;
case 322: str32 = "2" ; break;
case 331: str33 = "1" ; break;
case 332: str33 = "2" ; break;
}
}
private void winGame()
{
if(player1)
{
if(str11 == "1" && str12 == "1" && str13 == "1") //frm me:here i wanna write OR and i know the symbol of Or is "||" but everytime i wanna write it...got some error
(str21 == "1" && str22 == "1" && str23 == "1")
(str31 == "1" && str32 == "1" && str33 == "1")
MessageBox.Show(" You won!!!","winner",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else if(player1)
{
if(str11 == "2" && str12 == "2" && str13 == "2")
(str21 == "2" && str22 == "2" && str23 == "2")
(str31 == "2" && str32 == "2" && str33 == "2")
MessageBox.Show(" You won!!!",winner";
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
}
some1..pls help me...i know how to do..but the part is tat there is error...and i dunno wat to do...pls help :!: