Advertisement
Guest User

Untitled

a guest
Nov 16th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace ConnectFourProgram
  5. {
  6.   class ConnectFour
  7.   {
  8.     static void Main(string[] args)
  9.     {
  10.       int numberOfMoves = Int32.Parse(Console.ReadLine()); // this line is stupid af
  11.       int[] moves = Array.ConvertAll(Console.ReadLine().Split(' '), str => Int32.Parse(str));
  12.       // again, what's the point of this check? Well, I am including it because of the spec, but kinda pointless...
  13.       if (moves.Length > numberOfMoves)
  14.         throw new Exception("The number of moves you entered was different to the number of moves you said you would enter.");
  15.  
  16.       char[][] board = Enumerable.Repeat(Enumerable.Repeat('-', 7).ToArray(), 7).ToArray();
  17.       //foreach (int move in moves)
  18.       //  board = PlayMove(board, move);
  19.       board[3][2] = '*';
  20.  
  21.       PrintBoard(board);
  22.     }
  23.  
  24.     static char[][] PlayMove(char[][] board, int column)
  25.     {
  26.       if (column < 1 || column > 7)
  27.         throw new ArgumentOutOfRangeException("move/column was not between 1 and 7");
  28.       int row = 0;
  29.       while (row < 6 && board[row][column - 1] == '-') row++;
  30.       board[row][column - 1] = '*';
  31.       return board;
  32.     }
  33.  
  34.     static void PrintBoard(char[][] board)
  35.     {
  36.       foreach (char[] row in board)
  37.         Console.WriteLine(new string(row));
  38.     }
  39.   }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement