Ejemplo n.º 1
0
        public void MoveVehicle(Plateau plateau, ExplorationVehicle vehicle, IList <Rotation> rotations, IList <IPoint> busyPoints)
        {
            var vehiclePoint = new Point(vehicle.Point.PositionX, vehicle.Point.PositionY);
            var direction    = vehicle.GetDirection();

            var virtualVehicle   = ExplorationVehicles.Rover.Factory(vehiclePoint, direction, plateau);
            var destinationPoint = VehicleHelperFunctions.CheckBusyPointsRoute(virtualVehicle, rotations, busyPoints);

            VehicleHelperFunctions.CheckBorderLimits(plateau, destinationPoint);

            var vehicleCommandInvoker = new VehicleCommandInvoker();

            foreach (var rotation in rotations)
            {
                var vehicleCommand = VehicleCommandFactory.GetVehicleCommand(rotation, vehicle);
                vehicleCommandInvoker.Execute(vehicleCommand);
            }
        }
Ejemplo n.º 2
0
        public static IPoint CheckBusyPointsRoute(ExplorationVehicle virtualVehicle, IList <Rotation> rotations, IList <IPoint> busyPoints)
        {
            var vehicleCommandInvoker = new VehicleCommandInvoker();

            foreach (var rotation in rotations)
            {
                var vehicleCommand = VehicleCommandFactory.GetVehicleCommand(rotation, virtualVehicle);
                vehicleCommandInvoker.Execute(vehicleCommand);

                if (busyPoints
                    .Where(x => x.PositionX == virtualVehicle.Point.PositionX)
                    .Where(x => x.PositionY == virtualVehicle.Point.PositionY)
                    .Count() > 0)
                {
                    throw new HandledException(BusinessConstants.BUSY_POINT);
                }
            }
            return(virtualVehicle.Point);
        }