Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ConnectFourProgram
- {
- class ConnectFour
- {
- static void Main(string[] args)
- {
- int numberOfMoves = Int32.Parse(Console.ReadLine()); // this line is stupid af
- int[] moves = Array.ConvertAll(Console.ReadLine().Split(' '), str => Int32.Parse(str));
- // again, what's the point of this check? Well, I am including it because of the spec, but kinda pointless...
- if (moves.Length > numberOfMoves)
- throw new Exception("The number of moves you entered was different to the number of moves you said you would enter.");
- char[][] board = Enumerable.Repeat(Enumerable.Repeat('-', 7).ToArray(), 7).ToArray();
- //foreach (int move in moves)
- // board = PlayMove(board, move);
- board[3][2] = '*';
- PrintBoard(board);
- }
- static char[][] PlayMove(char[][] board, int column)
- {
- if (column < 1 || column > 7)
- throw new ArgumentOutOfRangeException("move/column was not between 1 and 7");
- int row = 0;
- while (row < 6 && board[row][column - 1] == '-') row++;
- board[row][column - 1] = '*';
- return board;
- }
- static void PrintBoard(char[][] board)
- {
- foreach (char[] row in board)
- Console.WriteLine(new string(row));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement