Advertisement
solidsnake

C#HandsOnGraded

May 2nd, 2013
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.63 KB | None | 0 0
  1. {
  2.     class Program
  3.     {
  4.         static void Main(string[] args)
  5.         {
  6.             string [] array = new string[9];
  7.             int counter = 0;
  8.  
  9.             try
  10.             {
  11.                 FileStream fs = new FileStream(@"C:\Users\user_2.F227-11\Desktop\board.txt", FileMode.Open);
  12.                 StreamReader readin = new StreamReader(fs);
  13.  
  14.                 while (!readin.EndOfStream)
  15.                 {
  16.                     string text = readin.ReadLine();
  17.                     string[] boardLocation = text.Split(' ');
  18.                    
  19.                     for (int i = 0; i < 3; i++)
  20.                     {
  21.                     array[i] = boardLocation[0];
  22.                     array[i+1] = boardLocation[1];
  23.                     array[i+2] = boardLocation[2];
  24.                     Console.Write(boardLocation[i] + " " + boardLocation[i + 1] + " " + boardLocation[i + 2]);
  25.                     Console.WriteLine();
  26.                     i = i+3;
  27.                     }
  28.  
  29.                 }
  30.  
  31.                 for (int a = 0; a <= 6; a++)
  32.                 {
  33.                     if (array[a] == "O" && array[a+1] == "O" && array[a+2] == "O")
  34.                     {
  35.                         Console.WriteLine("Player x wins");
  36.                     }
  37.                     else if (array[a] == "X" && array[a + 1] == "X" && array[a + 2] == "X")
  38.                     {
  39.                         Console.WriteLine("Player y wins");
  40.                     }
  41.  
  42.                 }
  43.  
  44.                 readin.Close;
  45.                 fs.Close;
  46.  
  47.             }
  48.  
  49.             catch (Exception e) { }
  50.             Console.ReadKey();
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement