コード例 #1
0
ファイル: BoardCreator.cs プロジェクト: 37407/Minesweeper
        public static GridPoint[,] CreateNewBoard(int width, int height, int minesToPlace)
        {
            GridPoint[,] board = new GridPoint[width, height];
            board.AddGridPointsToBoard();
            board.AddMinesToBoard(minesToPlace);
            board.CalculateAdjacentMineCount();

            foreach (var point in board)
            {
                GridPointHelper.SetDisplayCharacter(point);
            }

            return(board);
        }
コード例 #2
0
        public void AddMinesToBoard_AddsCorrectNumberOfMines()
        {
            var board = new GridPoint[3, 3];

            board.AddGridPointsToBoard();
            board.AddMinesToBoard(3);

            int placedMines = 0;

            foreach (var point in board)
            {
                if (point.IsMine)
                {
                    placedMines++;
                }
            }

            Assert.Equal(3, placedMines);
        }