Exemplo n.º 1
0
        public void TestInitializeVector()
        {
            var turtle = Turtle.GetInstance();

            turtle.InitializeVector(0, 1);
            turtle.Direction = DirectionEnum.North;
            Assert.AreEqual(turtle.Xposition, 0);
            Assert.AreEqual(turtle.Yposition, 1);
        }
Exemplo n.º 2
0
        public GameSetting PopulateGameSetting(List <string> listOfRows)
        {
            var gameSetting = new GameSetting();


            // Board
            var boardSize = GetGameProperty(listOfRows, "Board Size").FirstOrDefault();

            gameSetting.Board = new Board()
            {
                Size = boardSize
            };

            // Exit Position
            var exit         = GetGameProperty(listOfRows, "Exit Position").FirstOrDefault();
            var exitPosition = new ExitGame();

            exitPosition.InitializeVector(exit.GetLength(0), exit.GetLength(1));
            gameSetting.ExitPosition = exitPosition;

            // Mines
            var listOfMines = GetGameProperty(listOfRows, "Mine");

            foreach (var minePosition in listOfMines)
            {
                var mine = new Mine();
                mine.InitializeVector(minePosition.GetLength(0), minePosition.GetLength(1));
                gameSetting.ListOfMines.Add(mine);
            }

            // Starting Point
            const string turtleLabel     = "Starting Position";
            var          turtlePosition  = GetGameProperty(listOfRows, turtleLabel).FirstOrDefault();
            var          turtleDirection = GetTurtleStartingFacingPosition(listOfRows, turtleLabel);
            var          turtle          = Turtle.GetInstance();

            turtle.InitializeVector(turtlePosition.GetLength(0), turtlePosition.GetLength(1));
            turtle.Direction = turtleDirection;

            gameSetting.Turtle           = turtle;
            gameSetting.InitialDirection = turtleDirection;
            gameSetting.InitialPosition  = turtlePosition;

            return(gameSetting);
        }