Exemple #1
0
        public int Add(RoverMachine rover)
        {
            rover.Id = _rovers.Count;
            _rovers.Add(rover);

            return(_rovers.Count - 1);
        }
Exemple #2
0
        private RoverMachine rotateLeft(RoverMachine rover)
        {
            if (rover.Heading == 'N')
            {
                rover.Heading = 'W';
            }
            else if (rover.Heading == 'W')
            {
                rover.Heading = 'S';
            }
            else if (rover.Heading == 'S')
            {
                rover.Heading = 'E';
            }
            else if (rover.Heading == 'E')
            {
                rover.Heading = 'N';
            }

            return(rover);
        }
Exemple #3
0
        private RoverMachine advance(RoverMachine rover)
        {
            if (rover.Heading == 'S')
            {
                rover.YPos -= 1;
            }
            if (rover.Heading == 'N')
            {
                rover.YPos += 1;
            }
            if (rover.Heading == 'W')
            {
                rover.XPos -= 1;
            }
            if (rover.Heading == 'E')
            {
                rover.XPos += 1;
            }

            return(rover);
        }