using System; namespace connect4 { class Program { static void Main(string[] args) { //Setting column and row length //int rowLength = 3; //int columnLength = 3; //int checkOne = [0, 1]; char player = 'O'; //int emptyCellCheck = 6; //initializing 2D array (playing board) char[,] playingBoard = new char[7, 6]; initialize(playingBoard); while (true) { Console.Clear(); printBoard(playingBoard); // Call //Enter Row int row = 6; //Enter column Console.Write("Please enter column: "); int col = int.Parse(Console.ReadLine()); //Check for space taken /*if (playingBoard[6, col] == 'X' || playingBoard[6, col] == 'O') { emptyCellCheck = emptyCellCheck - 1; playingBoard[emptyCellCheck, col] = player; Console.WriteLine(emptyCellCheck); }*/ for (int i = 0; i < 8; i++) { //Invalid move if (row == -1)//Higher than the board { Console.WriteLine("INVALID MOVE"); if (player == 'X') { player = 'O'; } else { player = 'X'; } break; } //Checks chosen column if (playingBoard[row, col] == 'X' || playingBoard[row, col] == 'O') { row = row - 1; Console.WriteLine("SPACE TAKEN"); //Console.ReadLine(); } //If space is not taken else { //Update board with player playingBoard[row, col] = player; break; } } player = changeTurn(player); //checkWin(player); } } /*static void checkWin(player) { if (player == playingBoard[0, 0] && player == playingBoard[0, 0] && player == playingBoard[0, 0]) { } }*/ static char changeTurn(char player) { if (player == 'X') { return 'O'; } else { return 'X'; } } //initialize board (pulling set array) static void initialize(char[,] playingBoard) { for (int row = 0; row < 7; row++) { for (int col = 0; col < 6; col++) { playingBoard[row, col] = ' '; } } } //Generate board (pulling array) static void printBoard(char[,] playingBoard) { Console.WriteLine(" | 0| 1 | 2 | 3 | 4 | 5 |"); for (int row = 0; row < 7; row++) { Console.Write(row + "|"); for (int col = 0; col < 6; col++) { Console.Write(playingBoard[row, col]); Console.Write(" | "); } Console.WriteLine(); } } } }