Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace TicTacToe_Tura_Adrian
- {
- public partial class Form1 : Form
- {
- bool x = true, f = false;
- int c1 = 0, c2 = 0,c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0,n=0;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
- }
- void check_end()
- {
- if (n == 9)
- {
- f = true;
- txt_win.Text = "Remiză";
- }
- if(c1==c2 && c2==c3 && c1!=0)
- {
- f = true;
- if (c1 == 1)
- txt_win.Text = "X a câștigat";
- else
- txt_win.Text = "0 a câștigat";
- }
- if (c4 == c5 && c5 == c6 && c5 != 0)
- {
- f = true;
- if (c1 == 1)
- txt_win.Text = "X a câștigat";
- else
- txt_win.Text = "0 a câștigat";
- }
- if(c7==c8 && c8==c9 && c7!=0)
- {
- f = true;
- if (c1 == 1)
- txt_win.Text = "X a câștigat";
- else
- txt_win.Text = "0 a câștigat";
- }
- if(c1==c4 && c4==c7 && c1!=0)
- {
- f = true;
- if (c1 == 1)
- txt_win.Text = "X a câștigat";
- else
- txt_win.Text = "0 a câștigat";
- }
- if(c2==c5 && c5==c8 && c2!=0)
- {
- f = true;
- if (c2 == 1)
- txt_win.Text = "X a câștigat";
- else
- txt_win.Text = "0 a câștigat";
- }
- if(c3==c6 && c6==c9 && c3!=0)
- {
- f = true;
- if (c3 == 1)
- txt_win.Text = "X a câștigat";
- else
- txt_win.Text = "0 a câștigat";
- }
- if(c1==c5 && c5==c9 && c1!=0)
- {
- f = true;
- if (c1 == 1)
- txt_win.Text = "X a câștigat";
- else
- txt_win.Text = "0 a câștigat";
- }
- if(c3==c5 && c5==c7 && c3!=0)
- {
- f = true;
- if (c3 == 1)
- txt_win.Text = "X a câștigat";
- else
- txt_win.Text = "0 a câștigat";
- }
- }
- private void b1_Click(object sender, EventArgs e)
- {
- if(c1==0 && f==false)
- {
- n++;
- if (x == true)
- {
- c1 = 1;
- x = false;
- b1.Text = "X";
- txt_mut.Text = "0";
- }
- else
- {
- c1 = -1;
- x = true;
- b1.Text = "0";
- txt_mut.Text = "X";
- }
- }
- check_end();
- }
- private void b2_Click(object sender, EventArgs e)
- {
- if (c2 == 0 && f == false)
- {
- n++;
- if (x == true)
- {
- c2 = 1;
- x = false;
- b2.Text = "X";
- txt_mut.Text = "0";
- }
- else
- {
- c2 = -1;
- x = true;
- b2.Text = "0";
- txt_mut.Text = "X";
- }
- }
- check_end();
- }
- private void b3_Click(object sender, EventArgs e)
- {
- if (c3 == 0 && f == false)
- {
- n++;
- if (x == true)
- {
- c3 = 1;
- x = false;
- b3.Text = "X";
- txt_mut.Text = "0";
- }
- else
- {
- c3 = -1;
- x = true;
- b3.Text = "0";
- txt_mut.Text = "X";
- }
- }
- check_end();
- }
- private void b4_Click(object sender, EventArgs e)
- {
- if (c4 == 0 && f == false)
- {
- n++;
- if (x == true)
- {
- c4 = 1;
- x = false;
- b4.Text = "X";
- txt_mut.Text = "0";
- }
- else
- {
- c4 = -1;
- x = true;
- b4.Text = "0";
- txt_mut.Text = "X";
- }
- }
- check_end();
- }
- private void b5_Click(object sender, EventArgs e)
- {
- if (c5 == 0 && f == false)
- {
- n++;
- if (x == true)
- {
- c5 = 1;
- x = false;
- b5.Text = "X";
- txt_mut.Text = "0";
- }
- else
- {
- c5 = -1;
- x = true;
- b5.Text = "0";
- txt_mut.Text = "X";
- }
- }
- check_end();
- }
- private void b6_Click(object sender, EventArgs e)
- {
- if (c6 == 0 && f == false)
- {
- n++;
- if (x == true)
- {
- c6 = 1;
- x = false;
- b6.Text = "X";
- txt_mut.Text = "0";
- }
- else
- {
- c6 = -1;
- x = true;
- b6.Text = "0";
- txt_mut.Text = "X";
- }
- }
- check_end();
- }
- private void b7_Click(object sender, EventArgs e)
- {
- if (c7 == 0 && f == false)
- {
- n++;
- if (x == true)
- {
- c7 = 1;
- x = false;
- b7.Text = "X";
- txt_mut.Text = "0";
- }
- else
- {
- c7 = -1;
- x = true;
- b7.Text = "0";
- txt_mut.Text = "X";
- }
- }
- check_end();
- }
- private void b8_Click(object sender, EventArgs e)
- {
- if (c8 == 0 && f == false)
- {
- n++;
- if (x == true)
- {
- c8 = 1;
- x = false;
- b8.Text = "X";
- txt_mut.Text = "0";
- }
- else
- {
- c8 = -1;
- x = true;
- b8.Text = "0";
- txt_mut.Text = "X";
- }
- }
- check_end();
- }
- private void b9_Click(object sender, EventArgs e)
- {
- if (c9 == 0 && f == false)
- {
- n++;
- if (x == true)
- {
- c9 = 1;
- x = false;
- txt_mut.Text = "0";
- b9.Text = "X";
- }
- else
- {
- c9 = -1;
- x = true;
- b9.Text = "0";
- txt_mut.Text = "X";
- }
- }
- check_end();
- }
- private void btn_exit_Click(object sender, EventArgs e)
- {
- Application.Exit();
- }
- private void btn_reset_Click(object sender, EventArgs e)
- {
- c1 = c2 = c3 = c4 = c5 = c6 = c7 = c8 = c9 = n = 0;
- f = false;
- b1.Text = "";
- b2.Text = "";
- b3.Text = "";
- b4.Text = "";
- b5.Text = "";
- b6.Text = "";
- b7.Text = "";
- b8.Text = "";
- b9.Text = "";
- txt_win.Text = "";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement