Beispiel #1
0
        /// <summary>
        /// Sets up the Rover and ensures the starting Coordinate is available on the Plateau
        /// </summary>
        /// <param name="plateau">The Plateau for the Rover to move around</param>
        /// <param name="coordinate">The starting Coordinate for the Rover</param>
        /// <param name="direction">The initial Direction the Rover is facing</param>
        public Rover(Plateau plateau, Coordinate coordinate, Direction direction)
        {
            Plateau = plateau;
            Direction = direction;

            if (!Plateau.Coordinates.Contains(coordinate))
            {
                throw new CoordinatesOutOfBoundsException(coordinate.X, coordinate.Y);

            }

            Coordinate = coordinate;
        }
        private static void TestRovers(InputFile inputFile)
        {
            //Create the Plateau
            var plateau = new Plateau(inputFile.MaxCoordinate);

            //Create the first rover
            var rover1 = new Rover(plateau, inputFile.RoverPaths[0].StartCoordinate, inputFile.RoverPaths[0].StartDirection);
            //Move the rover
            rover1.SetPath(inputFile.RoverPaths[0].Path);
            //Test against expected result
            Assert.IsTrue(rover1.ToString().Equals("1 3 N"), string.Concat(rover1.ToString(), " should be 1 3 N"));

            //Create the second rover
            var rover2 = new Rover(plateau, inputFile.RoverPaths[1].StartCoordinate, inputFile.RoverPaths[1].StartDirection);
            //Move the rover
            rover2.SetPath(inputFile.RoverPaths[1].Path);
            //Test against expected result
            Assert.IsTrue(rover2.ToString().Equals("5 1 E"), string.Concat(rover2.ToString(), " should be 5 1 E"));
        }