Ejemplo n.º 1
0
        /// <summary>
        /// Runs the simulation for a given Rover
        /// </summary>
        /// <param name="rover">The Rover to run</param>
        public void RunRover(IRover rover)
        {
            while (rover.GetNextMove() != Action.Nothing)
            {
                // Copy the value of the current coordinates
                var currentCoordinates = new Point(rover.Coordinates.X, rover.Coordinates.Y);

                rover.Move();

                if (!rover.Coordinates.Equals(currentCoordinates))
                {
                    if (this.Planet.IsAreaOccupied(rover.Coordinates))
                    {
                        throw new InvalidOperationException("Rover position conflicts with another");
                    }

                    this.Planet.UpdateGridPosition(rover, currentCoordinates);
                }
            }
        }