示例#1
0
        // Method that reconstructs the board's layout from an array of marks to the string of marks delimited by the pipe character.
        // Returns the board's layout after modified.
        private string ReconstructLayout(GameBoard board, string[] marks)
        {
            board.CurrentLayout = "";

               for (int i = 0; i<9; i++ )
               {
               if (i == 8)
               {
                   board.CurrentLayout += (marks[i]);
               }
               else
               {
                   board.CurrentLayout += (marks[i] + "|");
               }
               }

               return board.CurrentLayout;
        }
示例#2
0
        // Method that makrs the GameBoard at the desired position. Returns true if move successfully place on the board.
        public bool MarkBoard(GameBoard board, int position)
        {
            string[] marks = board.CurrentLayout.Split('|');
            int convertedString;

            for (int i=0; i < marks.Length; i++)
            {
                if (Int32.TryParse(marks[i], out convertedString))
                {
                    if (position == convertedString)
                    {
                        marks[i] = symbol;

                        ReconstructLayout(board, marks);
                        return true;
                    }
                }
                // Otherwise this position has already been marked and cannot be marked again. Nothing else needs to be done.
            }

            return false;
        }
示例#3
0
        private void SelectBoardType()
        {
            string userSelection = "0";
            bool continueLoop = true;

            while (continueLoop)
            {
                System.Console.WriteLine("\nPlease Select the type of board to play on:");
                System.Console.WriteLine("(1) Standard Board");
                System.Console.WriteLine("(2) Bomb Board");
                System.Console.Write("Your selection: ");

                userSelection = System.Console.ReadLine();

                if (userSelection == "1")
                {
                    board = new StandardBoard();
                    continueLoop = false;
                }
                else if (userSelection == "2")
                {
                    // NOT YET IMPLEMENTED
                    System.Console.WriteLine("SORRY, THIS ISN'T INCLUDED YET. WILL START GAME WITH A STANDARD BOARD.");
                    board = new StandardBoard();
                    continueLoop = false;
                }
                else
                {
                    System.Console.WriteLine("\n\nInvalid selection");
                }

            }
        }