Example #1
0
        public void Is_wrong_data_can_Handle()
        {
            var          rg          = new MarsRover.Entities.Rover(6, 6, Compass.N);
            Plato        plato       = new Plato(5, 5);
            string       letters     = "MM";
            var          moveLetters = letters.ToCharArray();
            IPathChecker checker     = new PathChecker(plato);
            roverAction  action      = new roverAction(checker, rg);

            Assert.IsFalse(action.Run(letters.ToCharArray()), "Houston we have a Problem !");
        }
Example #2
0
        public void Is_rover_Can_Go_Ground()
        {
            var          rg          = new MarsRover.Entities.Rover(2, 2, Compass.N);
            Plato        plato       = new Plato(5, 5);
            string       letters     = "RRMMMMM";
            var          moveLetters = letters.ToCharArray();
            IPathChecker checker     = new PathChecker(plato);
            roverAction  action      = new roverAction(checker, rg);

            Assert.IsFalse(action.Run(letters.ToCharArray()), "How you can not go underground");
        }
Example #3
0
        public void Is_rover_Handle_Incoorect_Letter()
        {
            var          rg          = new MarsRover.Entities.Rover(2, 2, Compass.N);
            Plato        plato       = new Plato(5, 5);
            string       letters     = "F";
            var          moveLetters = letters.ToCharArray();
            IPathChecker checker     = new PathChecker(plato);
            roverAction  action      = new roverAction(checker, rg);

            Assert.IsFalse(action.Run(letters.ToCharArray()), "Can  Not go anywhere");
        }
Example #4
0
        public void Is_rover_Handle_Incoorect_Movement()
        {
            var          rg          = new MarsRover.Entities.Rover(2, 2, Compass.N);
            Plato        plato       = new Plato(5, 5);
            string       letters     = "MMMMM";
            var          moveLetters = letters.ToCharArray();
            IPathChecker checker     = new PathChecker(plato);
            roverAction  action      = new roverAction(checker, rg);

            Assert.IsFalse(action.Run(letters.ToCharArray()), "Heyy you are in space now!");
        }
        static void Main(string[] args)
        {
            //Get Plato Data
            var platoValues = Console.ReadLine().ToUpper().Replace(" ", "");
            var platoXValue = Convert.ToInt16(platoValues[0].ToString());
            var platoYValue = Convert.ToInt16(platoValues[1].ToString());

            Plato plato = new Plato(platoXValue, platoYValue);

            //Get input for 2 rovers;
            for (int i = 0; i <= 2; i++)
            {
                var initialroverPosition = Console.ReadLine().ToUpper().Replace(" ", "").ToCharArray();
                var roverXValue          = Convert.ToInt16(initialroverPosition[0].ToString());
                var roverYValue          = Convert.ToInt16(initialroverPosition[1].ToString());
                var position             = Convert.ToString(initialroverPosition[2]);

                //Set Compass Value  For Intial Value
                Compass roverPosition = Compass.N;
                if (position == "N")
                {
                    roverPosition = Compass.N;
                }
                else if (position == "E")
                {
                    roverPosition = Compass.E;
                }
                else if (position == "W")
                {
                    roverPosition = Compass.W;
                }
                else if (position == "G")
                {
                    roverPosition = Compass.G;
                }
                //Create rover Object
                Rover rover = new Rover(roverXValue, roverYValue, roverPosition);
                //Get move letters and turn for each;
                var moveLetters = Console.ReadLine().ToUpper().ToCharArray();
                //Check before Move
                IPathChecker checker = new PathChecker(plato);
                //Action class
                roverAction action = new roverAction(checker, rover);
                action.Run(moveLetters);
            }
        }