コード例 #1
0
        public List <RoverLocationModel> Start()
        {
            List <RoverLocationModel> roverLocations = new List <RoverLocationModel>();

            foreach (var rover in _model.RoverModels)
            {
                var movementMaps = rover.Movement.Maps;

                foreach (var movementMap in movementMaps)
                {
                    string orientationName = rover.Location.Orientation;
                    IMove  currentMover    = _movers[orientationName];

                    currentMover.Direction = movementMap.Direction;
                    currentMover.Location  = rover.Location;

                    if (!string.IsNullOrEmpty(movementMap.Direction))
                    {
                        currentMover.DetermineOrientation();
                    }

                    if (movementMap.IsMove)
                    {
                        currentMover.Move();
                    }
                }

                roverLocations.Add(new RoverLocationModel()
                {
                    Apsis       = rover.Location.Apsis,
                    Ordinate    = rover.Location.Ordinate,
                    Orientation = rover.Location.Orientation
                });
            }
            return(roverLocations);
        }