Ejemplo n.º 1
0
        static void StartTest(IRcCar car, Room room, string commands)
        {
            for (int i = 0; i < commands.Length; i++)
            {
                switch (commands[i])
                {
                case 'F':
                    car.MoveForward();
                    break;

                case 'B':
                    car.MoveBack();
                    break;

                case 'L':
                    car.MoveLeft();
                    break;

                case 'R':
                    car.MoveRight();
                    break;

                default:
                    break;
                }

                bool validMove = CheckMove(car, room);

                if (!validMove)
                {
                    Console.WriteLine("Test failed, car crashed into the wall trying to head {0} {1} meters from the bottom and {2} meters from the left", car.Heading, car.Y, car.X);
                    Console.ReadKey();
                }
            }

            Console.WriteLine("Test was successfull, car stopped {0} meters from the bottom and {1} meters from the left facing {2}", car.Y, car.X, car.Heading);
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        static void StartTest(IRcCar car, Room room, string commands)
        {
            for (int i = 0; i < commands.Length; i++)
            {
                switch (commands[i])
                {
                    case 'F':
                        car.MoveForward();
                        break;
                    case 'B':
                        car.MoveBack();
                        break;
                    case 'L':
                        car.MoveLeft();
                        break;
                    case 'R':
                        car.MoveRight();
                        break;
                    default:
                        break;
                }

                bool validMove = CheckMove(car, room);

                if (!validMove)
                {
                    Console.WriteLine("Test failed, car crashed into the wall trying to head {0} {1} meters from the bottom and {2} meters from the left", car.Heading, car.Y, car.X);
                    Console.ReadKey();
                }
            }

            Console.WriteLine("Test was successfull, car stopped {0} meters from the bottom and {1} meters from the left facing {2}", car.Y, car.X, car.Heading);
            Console.ReadKey();
        }