Пример #1
0
 // If the specified square is currently empty, fill it with mark and return true.
 // If the square is not empty, leave it as-is and return False.
 public bool SetSquare(int x, int y, Mark mark)
 {
     if (x < Board.GetLongLength(0) && y < Board.GetLongLength(1) && x > -1 && y > -1)
     {
         if (Board[x, y] == Mark.None)
         {
             Board[x, y] = mark;
         }
     }
     return(false);
 }
Пример #2
0
 // If there are still empty squares on the board, return false.
 // If there are no empty squares, return true.
 public bool IsBoardFull()
 {
     //Nested for loop for searching for empty board cells, uses GetLongLength() to find length of x and y axis
     for (int i = 0; i < board.GetLongLength(0); i++)
     {
         for (int j = 0; j < board.GetLongLength(1); j++)
         {
             if (board[i, j] == Mark.None)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #3
0
 // If the specified square is currently empty, fill it with mark and return true.
 // If the square is not empty, leave it as-is and return False.
 public bool SetSquare(int x, int y, Mark mark)
 {
     //Added validation for the users inputs
     if (x < GameBoard.GetLongLength(0) && y < GameBoard.GetLongLength(1) && x > -1 && y > -1)
     {
         if (GameBoard[x, y] == Mark.None)
         {
             GameBoard[x, y] = mark;
             return(true);
         }
     }
     return(false);
 }