Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace igra
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.         int potez = 1;
  20.         int click1 = 0;
  21.     int click2 = 0;
  22.     int click3 = 0;
  23.     int click4 = 0;
  24.     int click5 = 0;
  25.     int click6 = 0;
  26.     int click7 = 0;
  27.     int click8 = 0;
  28.     int click9 = 0;
  29.  
  30.     int IGRAC1 = 0, IGRAC2 = 0;
  31.  
  32.     private void button1_Click(object sender, EventArgs e)
  33.         {
  34.             if (click1 == 0){
  35.                 if (potez % 2 != 0){
  36.                     button1.Text = "X";
  37.                     click1++;
  38.                 }
  39.                 else{
  40.                     button1.Text = "O";
  41.                     click1++;
  42.                 }
  43.                 potez++;
  44.             }
  45.             else{
  46.                 button1.Text = button1.Text;
  47.             }
  48.             display();
  49.         }
  50.    
  51.     private void button2_Click(object sender, EventArgs e)
  52.         {
  53.             if (click2 == 0) {
  54.                 if (potez % 2 != 0){
  55.                     button2.Text = "X";
  56.                     click2++;
  57.                 }
  58.                 else {
  59.                     button2.Text = "O";
  60.                     click2++;
  61.                 }
  62.                 potez++;
  63.             }
  64.             else{
  65.                 button2.Text = button2.Text;
  66.             }
  67.             display();
  68.  
  69.         }
  70.  
  71.     private void button3_Click(object sender, EventArgs e)
  72.         {
  73.             if (click3 == 0)
  74.             {
  75.                 if (potez % 2 != 0)
  76.                 {
  77.                     button3.Text = "X";
  78.                     click3++;
  79.                 }
  80.                 else
  81.                 {
  82.                     button3.Text = "O";
  83.                     click3++;
  84.                 }
  85.                 potez++;
  86.             }
  87.             else
  88.             {
  89.                 button3.Text = button3.Text;
  90.             }
  91.             display();
  92.  
  93.         }
  94.  
  95.     private void button4_Click(object sender, EventArgs e)
  96.         {
  97.             if (click4 == 0)
  98.             {
  99.                 if (potez % 2 != 0)
  100.                 {
  101.                     button4.Text = "X";
  102.                     click4++;
  103.                 }
  104.                 else
  105.                 {
  106.                     button4.Text = "O";
  107.                     click4++;
  108.                 }
  109.                 potez++;
  110.             }
  111.             else
  112.             {
  113.                 button4.Text = button4.Text;
  114.             }
  115.             display();
  116.  
  117.         }
  118.  
  119.    
  120.          private void button5_Click(object sender, EventArgs e)
  121.         {
  122.             if (click5 == 0)
  123.             {
  124.                 if (potez % 2 != 0)
  125.                 {
  126.                     button5.Text = "X";
  127.                     click5++;
  128.                 }
  129.                 else
  130.                 {
  131.                     button5.Text = "O";
  132.                     click5++;
  133.                 }
  134.                 potez++;
  135.             }
  136.             else
  137.             {
  138.                 button5.Text = button5.Text;
  139.             }
  140.             display();
  141.  
  142.         }
  143.  
  144.         private void button6_Click(object sender, EventArgs e)
  145.         {
  146.             if (click6 == 0)
  147.             {
  148.                 if (potez % 2 != 0)
  149.                 {
  150.                     button6.Text = "X";
  151.                     click6++;
  152.                 }
  153.                 else
  154.                 {
  155.                     button6.Text = "O";
  156.                     click6++;
  157.                 }
  158.                 potez++;
  159.             }
  160.             else
  161.             {
  162.                 button6.Text = button6.Text;
  163.             }
  164.             display();
  165.  
  166.         }
  167.  
  168.    
  169.     private void button7_Click(object sender, EventArgs e)
  170.         {
  171.             if (click7 == 0)
  172.             {
  173.                 if (potez % 2 != 0)
  174.                 {
  175.                     button7.Text = "X";
  176.                     click7++;
  177.                 }
  178.                 else
  179.                 {
  180.                     button7.Text = "O";
  181.                     click7++;
  182.                 }
  183.                 potez++;
  184.             }
  185.             else
  186.             {
  187.                 button7.Text = button7.Text;
  188.             }
  189.             display();
  190.  
  191.         }
  192.  
  193.      private void button8_Click(object sender, EventArgs e)
  194.         {
  195.             if (click8 == 0)
  196.             {
  197.                 if (potez % 2 != 0)
  198.                 {
  199.                     button8.Text = "X";
  200.                     click8++;
  201.                 }
  202.                 else
  203.                 {
  204.                     button8.Text = "O";
  205.                     click8++;
  206.                 }
  207.                 potez++;
  208.             }
  209.             else
  210.             {
  211.                 button8.Text = button8.Text;
  212.             }
  213.             display();
  214.  
  215.         }
  216.        
  217.  
  218.     private void button9_Click(object sender, EventArgs e)
  219.         {
  220.             if (click9 == 0)
  221.             {
  222.                 if (potez % 2 != 0)
  223.                 {
  224.                     button9.Text = "X";
  225.                     click9++;
  226.                 }
  227.                 else
  228.                 {
  229.                     button9.Text = "O";
  230.                     click9++;
  231.                 }
  232.                 potez++;
  233.             }
  234.             else
  235.             {
  236.                 button9.Text = button9.Text;
  237.             }
  238.             display();
  239.  
  240.         }
  241.  
  242.        
  243.         public void display()
  244.         {
  245.             if (potez % 2 != 0)
  246.             {
  247.                 displayturn.Text = "IGRAC 1";
  248.             }
  249.             else
  250.             {
  251.                 displayturn.Text = "IGRAC 2";
  252.             }
  253.         }
  254.  
  255.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement