Esempio n. 1
0
        public void ProcessLine(string line, ProcessorState state)
        {
            string[]  vals = line.Split(" ");
            int       xStart;
            int       yStart;
            Direction dStart;

            try{
                xStart = Int32.Parse(vals[0]);
                yStart = Int32.Parse(vals[1]);
                dStart = DirectionStringConverter.StringToEnum(vals[2]);

                if (xStart > state.Plateau.GetXMax() || yStart > state.Plateau.GetYMax())
                {
                    LogManager.LogDebug("Rover initialization out of bounds");
                    throw new Exception("Rover initialization out of bounds");
                }

                Rover rover = new Rover(xStart, yStart, dStart, state.Plateau);

                LogManager.LogDebug("Initialized rover with values x = " + xStart + ", y = " +
                                    yStart + ", direction = " + DirectionStringConverter.EnumToString(dStart));

                state.Rover = rover;        //Update current rover in state
            }
            catch (Exception e) {
                throw new Exception("Problem initializing new rover: " + e.Message + ", line value:" + line);
            }
        }
Esempio n. 2
0
 //returns string representation of current rover position and direction
 //should be called after rover received all commands
 public override string ToString()
 {
     return(xPos + " " + yPos + " " + DirectionStringConverter.EnumToString(direction));
 }