Beispiel #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("----- INPUTS ----- ");
            //Get plateu boundaries
            string plateuBoundaries = Console.ReadLine();

            //Get First rover's instruction information and execution commands
            string firstRoverInstructions = Console.ReadLine();
            string firstRoverCommands     = Console.ReadLine();

            //Get Second rover's instruction information and execution commands
            string secondRoverInstructions = Console.ReadLine();
            string secondRoverCommands     = Console.ReadLine();


            Console.WriteLine("----- OUTPUTS -----");
            //Create Plateu boundaries
            Plateu plateu = new Plateu(plateuBoundaries);

            //Instantiate First Rover, Execute commands
            Rover firstRover = new Rover(firstRoverInstructions, plateu);

            firstRover.ExecuteCommands(firstRoverCommands.ToCharArray().ToList());
            firstRover.PrintRoverCurrentState();

            //Instantiate Second Rover, Execute commands
            Rover secondRover = new Rover(secondRoverInstructions, plateu);

            secondRover.ExecuteCommands(secondRoverCommands.ToCharArray().ToList());
            secondRover.PrintRoverCurrentState();

            Console.ReadKey();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter Upper Bound Values: ");
            string upperBoundValues = Console.ReadLine();
            Plateu marsPletau       = new Plateu(upperBoundValues);

            Console.WriteLine("Enter Position Values: ");
            string positionValues = Console.ReadLine();
            Rover  rover          = new Rover(positionValues, marsPletau);

            Console.WriteLine("Enter Movement Values: ");
            string movementValues = Console.ReadLine();

            rover.CommandRover(movementValues);

            Console.WriteLine(rover);
            Console.ReadKey();
        }
Beispiel #3
0
        public Rover(string positionValues, Plateu marsPlateu)
        {
            string[] positionValuesArray = positionValues.Split(' ');

            currentX = Convert.ToInt32(positionValuesArray[0]);
            currentY = Convert.ToInt32(positionValuesArray[1]);

            bool isValid = directionDegrees.
                           TryGetValue(Convert.ToChar(positionValuesArray[2]),
                                       out double radian);

            if (isValid)
            {
                directionVector = new Vector(radian, movementLength);
            }
            else
            {
                throw new ArgumentException(string.Format("Invalid Input {0}",
                                                          positionValuesArray[2]));
            }

            this.marsPlateu = marsPlateu;
        }