Advertisement
Festelo

C# code

Feb 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Windows.Media;
  12. using System.Windows.Media.Imaging;
  13. using System.Windows.Navigation;
  14. using System.Windows.Shapes;
  15.  
  16. namespace WpfApplication5
  17. {
  18.     /// <summary>
  19.     /// Interaction logic for MainWindow.xaml
  20.     /// </summary>
  21.     public partial class MainWindow : Window
  22.     {
  23.         public MainWindow()
  24.         {
  25.             InitializeComponent();
  26.         }
  27.  
  28.         private void Process(object sender, RoutedEventArgs e)
  29.         {
  30.             if ((string)(sender as Button).Content == "") { (sender as Button).Content = "X"; }
  31.             else return;
  32.             Random rnd = new Random();
  33.             Button[] button = { LD, MD, RD , LM, MM, RM, LU, MU, RU};
  34.             int random = 226;
  35.             int G = 0;
  36.             for (;;)
  37.             {
  38.                 random = rnd.Next(9);
  39.                 if ((string)button[random].Content == "")
  40.                 {
  41.                     button[random].Content = "0";
  42.                     break;
  43.                 }
  44.                 else G++;
  45.                 if(G == 9) break;
  46.             }
  47.             if((string)LD.Content == "X" && (string)MD.Content == "X" && (string)RD.Content == "X") MessageBox.Show("Win");
  48.             else if((string)LM.Content == "X" && (string)MM.Content == "X" && (string)RM.Content == "X") MessageBox.Show("Win");
  49.             else if ((string)LU.Content == "X" && (string)MU.Content == "X" && (string)RU.Content == "X") MessageBox.Show("Win");
  50.  
  51.             else if ((string)LD.Content == "X" && (string)LM.Content == "X" && (string)LU.Content == "X") MessageBox.Show("Win");
  52.             else if ((string)MD.Content == "X" && (string)MM.Content == "X" && (string)MU.Content == "X") MessageBox.Show("Win");
  53.             else if ((string)RD.Content == "X" && (string)RM.Content == "X" && (string)RU.Content == "X") MessageBox.Show("Win");
  54.  
  55.             else if ((string)LU.Content == "X" && (string)MM.Content == "X" && (string)RD.Content == "X") MessageBox.Show("Win");
  56.             else if ((string)RU.Content == "X" && (string)MM.Content == "X" && (string)LD.Content == "X") MessageBox.Show("Win");
  57.             //
  58.             //
  59.             else if ((string)LD.Content == "0" && (string)MD.Content == "0" && (string)RD.Content == "0") MessageBox.Show("Lose");
  60.             else if ((string)LM.Content == "0" && (string)MM.Content == "0" && (string)RM.Content == "0") MessageBox.Show("Lose");
  61.             else if ((string)LU.Content == "0" && (string)MU.Content == "0" && (string)RU.Content == "0") MessageBox.Show("Lose");
  62.  
  63.             else if ((string)LD.Content == "0" && (string)LM.Content == "0" && (string)LU.Content == "0") MessageBox.Show("Lose");
  64.             else if ((string)MD.Content == "0" && (string)MM.Content == "0" && (string)MU.Content == "0") MessageBox.Show("Lose");
  65.             else if ((string)RD.Content == "0" && (string)RM.Content == "0" && (string)RU.Content == "0") MessageBox.Show("Lose");
  66.  
  67.             else if ((string)LU.Content == "0" && (string)MM.Content == "0" && (string)RD.Content == "0") MessageBox.Show("Lose");
  68.             else if ((string)RU.Content == "0" && (string)MM.Content == "0" && (string)LD.Content == "0") MessageBox.Show("Lose");
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement