public void BecauseOf()
 {
     var input = "LMLMLMLMM";
     var plateau = new Plateau(5, 5);
     var rover = new Rover(new Position(1, 2), "N", plateau);
     _commandProcessorResult = new CommandProcessor().Process(input, rover, plateau);
 }
 public virtual bool IsSatisfiedBy(Position position, Plateau plateau)
 {
     return ((position.XCoordinate <= plateau.MaximumXCoordinate) &&
         (position.YCoordinate <= plateau.MaximumYCoordinate) &&
         (position.XCoordinate >= 0) &&
         (position.YCoordinate >= 0));
 }
        protected void GivenRoverWithDirection(IDirectionState direction)
        {
            var coordinate = new Coordinate(5, 5);
            var plateau = new Plateau(100, 100);

            Rover = new Rover(plateau, coordinate, direction);
        }
Пример #4
0
        public void cannot_place_rover_where_another_rover_is()
        {
            var mars = new Plateau(new Size(10, 10));
            mars.PlaceRover(new Rover(new Coordinate(2, 2), CameraDirection.North));

            Assert.Throws<InvalidOperationException>(() => mars.PlaceRover(new Rover(new Coordinate(2, 2), CameraDirection.North)));
        }
Пример #5
0
        public void cannot_move_rover_outside_of_plateau(int x, int y, CameraDirection cameraDirection)
        {
            var mars = new Plateau(new Size(1, 1));
            var rover = new Rover(new Coordinate(x, y), cameraDirection);
            mars.PlaceRover(rover);

            Assert.Throws<RoverCannotMoveException>(() => rover.SendInstruction(RoverInstruction.M));
        }
 public void ShouldParseValidInput()
 {
     var parser = new PlateauParser();
     var result = parser.Parse("1 2");
     var expected = new Plateau(1, 2);
     result.Width.ShouldEqual(expected.Width);
     result.Height.ShouldEqual(expected.Height);
 }
Пример #7
0
        public void when_validation_a_position()
        {
            var plateau = new Plateau(5, 5);
            var position = new Position(2, 2, Direction.North);

            var isValidPosition = plateau.IsPositionOnPlateau(position);

            "It should successfully validate the position".AssertThat(isValidPosition, Is.True);
        }
Пример #8
0
        public void when_validation_a_position_and_the_Y_coordinate_is_to_low()
        {
            var plateau = new Plateau(5, 5);
            var position = new Position(2, -2, Direction.North);

            var isValidPosition = plateau.IsPositionOnPlateau(position);

            "It should NOT successfully validate the position".AssertThat(isValidPosition, Is.False);
        }
Пример #9
0
 public Robot(int robotId, IPosition langdingPosition, IHeading heading, IList<char> movingInstructions,
     Plateau targetPlateau)
 {
     _robotId = robotId;
     CurrentPosition = langdingPosition;
     Heading = heading;
     _movingInstructions = movingInstructions;
     TargetPlateau = targetPlateau;
 }
Пример #10
0
        public void cannot_move_rover_if_it_will_collide_with_another_rover()
        {
            var mars = new Plateau(new Size(3, 3));
            var rover = new Rover(new Coordinate(1, 1), CameraDirection.North);
            mars.PlaceRover(rover);

            var rover2 = new Rover(new Coordinate(1, 2), CameraDirection.South);
            mars.PlaceRover(rover2);

            Assert.Throws<RoverCannotMoveException>(() => rover2.SendInstruction(RoverInstruction.M));
        }
Пример #11
0
        /// <summary>
        /// Create plateau
        /// </summary>
        /// <returns></returns>
        public static Plateau initPlateau()
        {
            Plateau mars = new Plateau();

            CommonOperations.WriteConsole("Plateau created. -> " + mars.id + "-" + mars.name, ConsoleWriteType.N);

            mars.size = SetSize();

            CommonOperations.WriteConsole(mars.name + " size is: " + mars.size, ConsoleWriteType.N);
            CommonOperations.WriteConsole("---------------------------", ConsoleWriteType.N);
            return(mars);
        }
Пример #12
0
        public void GivenTheRoverIsInStartPosition(int x, int y, string facing)
        {
            var direction = GetDirection(facing);

            var plateau = new Plateau(5, 5);
            var initialPosition = new Position(x, y, direction);
            _rover = new Rover(initialPosition, plateau, new InstructionHandler());

            Assert.That(_rover.Position.X, Is.EqualTo(x));
            Assert.That(_rover.Position.Y, Is.EqualTo(y));
            Assert.That(_rover.Position.Direction, Is.EqualTo(direction));
        }
 public void BecauseOf()
 {
     try
     {
         var plateau = new Plateau(5, 5);
         new CreateRoverCommand().Execute(new string[] { "N", "5", "N" }, null, plateau);
     }
     catch (ApplicationException)
     {
         _exceptionThrown = true;
     }
 }
Пример #14
0
        public void RunCommandList_InvalidCommandLetters_ExceptionThrown(string commandLetters)
        {
            var plateau            = new Plateau("5 5");
            var mockCommandFactory = new Mock <ICommandFactory>();

            var rover = new Rover(plateau, mockCommandFactory.Object);

            Assert.Throws <Exception>(
                () => rover.RunCommandList(new RunCommandListDTO {
                CommandLetters = commandLetters
            }));
        }
Пример #15
0
        static void Main(string[] args)
        {
            try
            {
                //Ensure there is command line arguement (filename containing paths)
                if (!args.Length.Equals(1))
                {
                    throw new ApplicationException("Expecting one command line parameter.");
                }

                //Load the data from file specified in the command line argument
                var inputFile = InputFileHelper.LoadInputFile(args[0]);

                //Create the Plateau
                var plateau = new Plateau(inputFile.MaxCoordinate);

                //Loop through the paths for each rover
                foreach (var roverPath in inputFile.RoverPaths)
                {
                    try
                    {
                        //Create the Rover
                        var rover = new Rover(plateau, roverPath.StartCoordinate, roverPath.StartDirection);
                        //Set the Rover on it's path
                        rover.SetPath(roverPath.Path);
                        //Output the final location on the plateau
                        Console.WriteLine(rover.ToString());
                    }
                    catch (CoordinatesOutOfBoundsException ex)
                    {
                        Console.WriteLine(string.Concat("A CoordinatesOutOfBoundsException has occurred: ", ex.Message));
                    }
                    catch (InvalidCoordinateException ex)
                    {
                        Console.WriteLine(string.Concat("A InvalidCoordinateException has occurred: ", ex.Message));
                    }
                    catch (InvalidPathException ex)
                    {
                        Console.WriteLine(string.Concat("A InvalidPathException has occurred: ", ex.Message));
                    }
                }

                Console.WriteLine();
                Console.WriteLine("Press enter to end.");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine(string.Concat("An unexpected error has occurred: ", ex.Message));
                Console.WriteLine("Press enter to end.");
                Console.ReadLine();
            }
        }
Пример #16
0
        public void Should_SecondRoverInMars_Success_Result()
        {
            //Given
            Plateau plateauTwo  = new Plateau(new Position(5, 5));
            Rover   secondRover = new Rover(plateauTwo, new Position(3, 3), Direction.E);

            // Act
            secondRover.Run("MMRMMRMRRM");

            //Assert
            Assert.Equal("5 1 E", secondRover.LastRoverPosition());
        }
Пример #17
0
        public void DoesStartEngine_ShouldMoveRightPositionAndDirection_PlateauLocationCoordinatesData(List <int> maxRange, Compass targetLocation, int xCoordinate, int yCoordinate, string moves, string expected)
        {
            Plateau plateau = new Plateau(maxRange);


            Rover rover = new Rover(plateau, targetLocation, xCoordinate, yCoordinate);

            rover.StartTheEngine(moves);
            var result = $"{rover.X}{rover.Y}{rover.TargetDirection}";

            Assert.Equal(result, expected);
        }
Пример #18
0
            public void When_point_is_outside_size_boundary_returns_false(int boundaryX, int boundaryY, int attemptedX, int attemptedY)
            {
                var size    = new Size(boundaryX, boundaryY);
                var point   = new Point(attemptedX, attemptedY);
                var plateau = new Plateau();

                plateau.SetSize(size);

                var isValidPoint = plateau.IsValid(point);

                Assert.That(!isValidPoint);
            }
Пример #19
0
            public void When_point_is_within_size_boundary_returns_true(int boundaryX, int boundaryY, int attemptedPointX, int attemptedPointY)
            {
                var size    = new Size(boundaryX, boundaryY);
                var point   = new Point(attemptedPointX, attemptedPointY);
                var plateau = new Plateau();

                plateau.SetSize(size);

                var isValidPoint = plateau.IsValid(point);

                Assert.That(isValidPoint);
            }
Пример #20
0
        public void Should_ArgumentNullException_When_EmptyCommandInput()
        {
            //Given
            Plateau plateau = new Plateau(new Position(5, 5));
            Rover   rover   = new Rover(plateau, new Position(1, 2), Direction.N);

            // Act
            var ex = Assert.ThrowsAny <ArgumentException>(() => rover.Run(string.Empty));

            //Assert
            Assert.Equal("command cannot be empty", ex.Message);
        }
Пример #21
0
        public void Should_ArgumentNullException_When_NullCommandInput()
        {
            //Given
            Plateau plateau = new Plateau(new Position(5, 5));
            Rover   rover   = new Rover(plateau, new Position(1, 2), Direction.N);

            // Act
            var ex = Assert.ThrowsAny <ArgumentException>(() => rover.Run(null));

            //Assert
            Assert.Equal("Value cannot be null. (Parameter 'commands')", ex.Message);
        }
Пример #22
0
        public void Should_ArgumentException_When_IncorrectInput()
        {
            //Given
            Plateau plateau = new Plateau(new Position(5, 5));
            Rover   rover   = new Rover(plateau, new Position(1, 2), Direction.N);

            // Act
            var ex = Assert.ThrowsAny <ArgumentException>(() => rover.Run("LMAMMM"));

            //Assert
            Assert.Equal("Invalid value: A", ex.Message);
        }
Пример #23
0
        public void Should_ArgumentException_When_OutBoundsInput()
        {
            //Given
            Plateau plateau = new Plateau(new Position(5, 5));
            Rover   rover   = new Rover(plateau, new Position(5, 2), Direction.N);

            // Act
            var ex = Assert.ThrowsAny <ArgumentException>(() => rover.Run("RMRMRMMM"));

            //Assert
            Assert.Equal("You cannot go beyond the boundaries of Plateau", ex.Message);
        }
Пример #24
0
        public void ExecuteCommand_ShouldBeException_GetInvalidCommandException(int width, int height, int pointX, int pointY, Rotation rotation, string command)
        {
            var plateau  = new Plateau(width, height);
            var location = new Location(pointX, pointY);
            var rover    = new MarsRover();

            rover.SetPlateau(plateau);
            rover.SetLocation(location, rotation);
            var roverManager = new MarsRoverManager(rover);

            Assert.Throws <InvalidCommandException>(() => roverManager.ExecuteCommand(command));
        }
Пример #25
0
        public void TestErreursDiverses()
        {
            Plateau.Init();
            Tuile tuile1 = new Tuile('c', 'e', @"exemple");
            Tuile tuile2 = new Tuile('c', 'r', @"exemple");
            Tuile tuile3 = new Tuile('r', 'e', @"exemple");
            Tuile tuile4 = new Tuile('r', 'r', @"exemple");

            Plateau.SetCase(1, 2, tuile2);
            Assert.AreEqual(false, Plateau.ValiderPlacement(1, 2, tuile1));   //emplacement deja utilisé
            Assert.AreEqual(false, Plateau.ValiderPlacement(19, 19, tuile1)); //case avec aucune tuiles autour
        }
        public void Rover_Move_Success_Test(int plateauX, int plateauY, int x, int y, string direction, string instuction, int expectedX, int expectedY, CardinalDirection expectedDirection)
        {
            var rover   = new Rover();
            var plateau = new Plateau(plateauX, plateauY);

            rover.Init(x, y, direction, instuction);
            rover.Move(plateau);

            Assert.Equal(expectedX, rover.X);
            Assert.Equal(expectedY, rover.Y);
            Assert.Equal(expectedDirection, rover.Direction);
        }
Пример #27
0
        public void Should_FirstRoverInMars_Success_Result()
        {
            //Given
            Plateau plateauOne = new Plateau(new Position(5, 5));
            Rover   firstRover = new Rover(plateauOne, new Position(1, 2), Direction.N);

            // Act
            firstRover.Run("LMLMLMLMM");

            //Assert
            Assert.Equal("1 3 N", firstRover.LastRoverPosition());
        }
Пример #28
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("Enter Plateau upper coordinate..");
                var plateauCoordinateInput = Console.ReadLine();
                var plateau = new Plateau(plateauCoordinateInput);

                Console.WriteLine("Enter first rover position..");
                var firstRoverPositionInput = Console.ReadLine();

                ICommandFactory commandFactory = new CommandFactory();
                var             firstRover     = new Rover(plateau, commandFactory);

                firstRover.SetPosition(new SetPositionDTO {
                    PositionLetter = firstRoverPositionInput
                });

                Console.WriteLine("Enter first rover commands..");
                var firstRoverCommandsInput = Console.ReadLine();

                firstRover.RunCommandList(new RunCommandListDTO {
                    CommandLetters = firstRoverCommandsInput
                });

                Console.WriteLine("Enter second rover position..");
                var secondRoverPositionInput = Console.ReadLine();

                var secondRover = new Rover(plateau, commandFactory);
                secondRover.SetPosition(new SetPositionDTO {
                    PositionLetter = secondRoverPositionInput
                });

                Console.WriteLine("Enter second rover commands..");
                var secondRoverCommandsInput = Console.ReadLine();

                secondRover.RunCommandList(new RunCommandListDTO {
                    CommandLetters = secondRoverCommandsInput
                });

                Console.WriteLine("Output:");
                Console.WriteLine(firstRover.GetPosition());
                Console.WriteLine(secondRover.GetPosition());
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error message: {ex.Message}");
            }

            Console.WriteLine("Press enter any key to exit..");
            Console.ReadKey();
        }
Пример #29
0
    /// <summary>
    /// Construit un batiment au bout d'une ligne droite d'au moins 3 batiments alignés de la même couleur, dans n'importe quelle directions.
    /// </summary>
    /// <remarks>Seul le balayage horizontale est implémenté.</remarks>
    /// <param name="coordonnee">Coordonnee du terrain à construire la maison</param>
    /// <param name="joueur">Joueur qui lance le bonus</param>
    /// <param name="plateau">Plateau de jeu</param>
    /// <returns>True si bonus bien activé, false sinon.</returns>
    public static bool Taverne(Coordonnee coordonnee, Joueur joueur, Plateau plateau)
    {
        // Verification que le clic est bien réalisé à l'interieur du plateau.
        if (coordonnee == null)
        {
            return(false);
        }

        // Verification que le joueur possède bien le bonus.
        if (!joueur.ListeBonus.Contains(TypeTerrain.TAVERNE))
        {
            return(false);
        }

        // Verification que le joeur a cliqué sur un terrain constructible.
        if (plateau[coordonnee].Type != TypeTerrain.PRAIRIE && plateau[coordonnee].Type != TypeTerrain.FORET &&
            plateau[coordonnee].Type != TypeTerrain.FLEUR && plateau[coordonnee].Type != TypeTerrain.DESERT &&
            plateau[coordonnee].Type != TypeTerrain.CANYON)
        {
            return(false);
        }

        // Verification que la case est inoccupée.
        if (plateau[coordonnee].Couleur != Couleur.AUCUNE)
        {
            return(false);
        }

        // posable est une Liste qui possède les coordonnées éligible d'utilisation du bonus.
        List <Coordonnee> posables = new List <Coordonnee>();

        // Parcours de toute les cases du plateau. On verifie par 3 balayages : 1 sur l'axe des x, et deux en diagonale.

        // Balayage en X (gauche -> droite)
        posables.AddRange(BalayageHorizontale(plateau, joueur));

        // Balayage en diagonale (gauche -> droite)

        // Balayage en diagonale (droite -> gauche)
        foreach (Coordonnee coord in posables)
        {
            if (coord.Equals(coordonnee))
            {
                plateau[coordonnee].Couleur = joueur.Couleur;
                joueur.NbMaisons--;
                joueur.m_maisonsPlacees.Add(coordonnee);
                return(true);
            }
        }

        return(false);
    }
Пример #30
0
        public void AreCoordinatesInside_Plateau55AndCoordinates5Minus1_TheMethodShouldReturnFalse()
        {
            // Arrange
            var upperLeft = new Coordinates(5, 5);
            var plateau = new Plateau(upperLeft);
            var coordinatesToCheck = new Coordinates(5, -1);

            // Act
            var result = plateau.AreCoordinatesInside(coordinatesToCheck);

            // Assert
            Assert.That(result, Is.False);
        }
Пример #31
0
        public void Example1()
        {
            var plateau = new Plateau("5 5");

            var rovers = new List <IRover>()
            {
                new Rover("1 2 N", "LMLMLMLMM")
            };

            plateau.Explore(rovers);

            Assert.AreEqual("1 3 N", rovers[0].ToString());
        }
Пример #32
0
        public void MoveToFinalLocation_33_33N_RMLMM()
        {
            var rover   = new Rover(3, 3, Direction.North);
            var plateau = new Plateau(5, 5);

            var result = roverMoveQueryHandler.Handle(new RoverMoveQuery {
                Rover = rover, Commands = "RMLMM", Plateau = plateau
            }, CancellationToken.None).Result;

            result.Data.Position.X.Should().Be(4);
            result.Data.Position.Y.Should().Be(5);
            result.Data.Direction.Should().Be(Direction.North);
        }
Пример #33
0
        public void Example2()
        {
            var plateau = new Plateau("5 5");

            var rovers = new List <IRover>()
            {
                new Rover("3 3 E", "MMRMMRMRRM")
            };

            plateau.Explore(rovers);

            Assert.AreEqual("5 1 E", rovers[0].ToString());
        }
Пример #34
0
        public void PlateauBoundriesNotBigEnoughToMoveWest()
        {
            var plateau = new Plateau("1 1");

            var rovers = new List <IRover>()
            {
                new Rover("0 0 W", "MM")
            };

            var ex = Assert.Throws <Exception>(() => plateau.Explore(rovers));

            Assert.That(ex.Message, Is.EqualTo("The boundaries of the plateau are not big enough to move west"));
        }
Пример #35
0
        public Dictionary <Rover, bool> setRoverLocation(Plateau plateau, int xCoordinate, int yCoordinate, enumMainDirections mainDirection)
        {
            Dictionary <Rover, bool> response = new Dictionary <Rover, bool>();

            Rover rover = new Rover()
            {
                xCoordinate   = xCoordinate,
                yCoordinate   = yCoordinate,
                mainDirection = mainDirection
            };

            return(_SLocation.isInvalidLocation(plateau, rover));
        }
Пример #36
0
        public void when_moving_the_second_rover()
        {
            var plateau = new Plateau(5, 5);
            var initialPosition = new Position(3, 3, Direction.East);
            var rover = new Rover(initialPosition, plateau, new InstructionHandler());
            rover.ProcessInstructions("MMRMMRMRRM");

            var position = rover.Position;

            "It should be at x coordinate".AssertThat(position.X, Is.EqualTo(5));
            "It should be at y coordinate".AssertThat(position.Y, Is.EqualTo(1));
            "It should be facing north".AssertThat(position.Direction, Is.EqualTo(Direction.East));
        }
Пример #37
0
        public void Test_MoveCommand()
        {
            var plateau    = new Plateau(5, 5);
            var coordinate = new Coordinate(1, 2);
            var direction  = DirectionParser.GetDirection('N');
            var rover      = new MarsRover(plateau, coordinate, direction);

            var moveCommand = new MoveCommand();

            moveCommand.Execute(rover);

            Assert.AreEqual("1 3 N", rover.GetCurrentLocation());
        }
Пример #38
0
        public void AreCoordinatesInside_Plateau55AndCoordinatesMinus15_ReturnFalse()
        {
            // Arrange
            var upperRight         = new Coordinates(5, 5);
            var plateau            = new Plateau(upperRight);
            var coordinatesToCheck = new Coordinates(-1, 5);

            // Act
            var result = plateau.AreCoordinatesInside(coordinatesToCheck);

            // Assert
            Assert.That(result, Is.False);
        }
Пример #39
0
        public void AreCoordinatesInside_Plateau55AndCoordinates00_ReturnTrue()
        {
            // Arrange
            var upperRight         = new Coordinates(5, 5);
            var plateau            = new Plateau(upperRight);
            var coordinatesToCheck = new Coordinates(0, 0);

            // Act
            var result = plateau.AreCoordinatesInside(coordinatesToCheck);

            // Assert
            Assert.That(result, Is.True);
        }
Пример #40
0
        internal override void Execute(Rover rover, Plateau plateau)
        {
            var currentFacingIndex = (int)rover.Position.CurrentFacing;
            var newFacingIndex     = currentFacingIndex - 1;

            if (newFacingIndex < 0)
            {
                newFacingIndex = Enum.GetValues(typeof(Position.Facing)).Length - 1;
            }
            var newFacing = (Position.Facing)newFacingIndex;

            SetNewPosition(rover, new Position(rover.Position.X, rover.Position.Y, newFacing));
        }
Пример #41
0
        public void TestFonctionEvaluationComplexe()
        {
            Plateau       plateau   = new Plateau(9, 9);
            Joueur        moi       = new Joueur(new Position(1, 0), 0, 6);
            Joueur        opposant  = new Joueur(new Position(8, 8), 1, 6);
            List <Joueur> opposants = new List <Joueur>();

            opposants.Add(opposant);
            plateau.Joueurs = Player.GetAllJoueurOrder(moi, opposants);
            var result = plateau.Evaluation();

            Assert.AreEqual(result, 3);
        }
Пример #42
0
        public void when_moving_the_first_rover()
        {
            var plateau = new Plateau(5, 5);
            var initialPosition = new Position(1, 2, Direction.North);
            var rover = new Rover(initialPosition, plateau, new InstructionHandler());
            rover.ProcessInstructions("LMLMLMLMM");

            var position = rover.Position;

            "It should be at x coordinate".AssertThat(position.X, Is.EqualTo(1));
            "It should be at y coordinate".AssertThat(position.Y, Is.EqualTo(3));
            "It should be facing north".AssertThat(position.Direction, Is.EqualTo(Direction.North));
        }
Пример #43
0
        public void RoverMoveQuery_55_12N_LMLMLMLMM()
        {
            var rover   = new Rover(1, 2, Direction.North);
            var plateau = new Plateau(5, 5);

            var result = roverMoveQueryHandler.Handle(new RoverMoveQuery {
                Rover = rover, Commands = "LMLMLMLMM", Plateau = plateau
            }, CancellationToken.None).Result;

            result.Data.Position.X.Should().Be(1);
            result.Data.Position.Y.Should().Be(3);
            result.Data.Direction.Should().Be(Direction.North);
        }
Пример #44
0
        public void RoverMoveQuery_55_33E_MMRMMRMRRM()
        {
            var rover   = new Rover(3, 3, Direction.East);
            var plateau = new Plateau(5, 5);

            var result = roverMoveQueryHandler.Handle(new RoverMoveQuery {
                Rover = rover, Commands = "MMRMMRMRRM", Plateau = plateau
            }, CancellationToken.None).Result;

            result.Data.Position.X.Should().Be(5);
            result.Data.Position.Y.Should().Be(1);
            result.Data.Direction.Should().Be(Direction.East);
        }
Пример #45
0
        public void InvalidInstructionCharDetected()
        {
            var plateau = new Plateau("5 5");

            var rovers = new List <IRover>()
            {
                new Rover("0 0 N", "ABC")
            };

            var ex = Assert.Throws <Exception>(() => plateau.Explore(rovers));

            Assert.That(ex.Message, Is.EqualTo("Invalid instruction character detected"));
        }
Пример #46
0
        public void Example3()
        {
            var plateau = new Plateau("3 3");

            var rovers = new List <IRover>()
            {
                new Rover("0 0 E", "MLMRMLMRMLM")
            };

            plateau.Explore(rovers);

            Assert.AreEqual("3 3 N", rovers[0].ToString());
        }
        public virtual Tuple<string, Rover, Plateau> Execute(
            string[] commandElements, Rover rover, Plateau plateau)
        {
            var xCoordinate = 0;
            var yCoordinate = 0;

            if (!int.TryParse(commandElements[0], out xCoordinate) ||
                !int.TryParse(commandElements[1], out yCoordinate))
            {
                throw new ApplicationException("Invalid Command. Plateau maximum values must be specified with integers.");
            }

            var newPlateau = new Plateau(xCoordinate, yCoordinate);
            return new Tuple<string, Rover, Plateau>("", rover, newPlateau);
        }
Пример #48
0
        public PanelTable()
        {
            InitializeComponent();
            Plateau = new Plateau();
            Plateau.ScoreChange += new EventHandler(Plateau_ScoreChange);
            Dessinateur.TableDessinee += Dessinateur_TableDessinee;

            checkedListBox.SetItemChecked(0, true);
            checkedListBox.SetItemChecked(1, true);

            toolTip.SetToolTip(btnTeleportRPFace, "Téléportation de face");
            toolTip.SetToolTip(btnTeleportRPCentre, "Téléportation de centre");
            toolTip.SetToolTip(btnPathRPFace, "Path finding de face");
            toolTip.SetToolTip(btnPathRPCentre, "Path finding du centre");
        }
        public virtual Tuple<string, Rover, Plateau> Execute(
            string[] commandElements, Rover rover, Plateau plateau)
        {
            var roverCommands = _roverCommandParser.Parse(commandElements);

            foreach (var roverCommand in roverCommands)
            {
                roverCommand.Execute(rover);
            }

            var response = string.Format("{0} {1} {2}",
                rover.CurrentPosition.XCoordinate,
                rover.CurrentPosition.YCoordinate, rover.Orientation);

            return new Tuple<string, Rover, Plateau>(response, rover, plateau);
        }
        public virtual Tuple<string, Rover, Plateau> Execute(
            string[] commandElements, Rover rover, Plateau plateau)
        {
            var tempInt = 0;
            var xCoordinate = 0;
            var yCoordinate = 0;

            if (!int.TryParse(commandElements[0], out xCoordinate) ||
                !int.TryParse(commandElements[1], out yCoordinate) ||
                int.TryParse(commandElements[2], out tempInt))
            {
                throw new ApplicationException("Invalid Command. The rover creation command requires two integers followed by an alpha character.");
            }

            var newRover = new Rover(
                new Position(xCoordinate, yCoordinate), commandElements[2], plateau);
            return new Tuple<string, Rover, Plateau>("", newRover, plateau);
        }
Пример #51
0
 public Rover(Plateau plateau, Coordinate coordinate, IDirectionState direction)
 {
     this.Coordinate = coordinate;
     this.Direction = direction;
     this.plateau = plateau;
 }
 public void BecauseOf()
 {
     var input = "MMRMMRMRRM";
     var plateau = new Plateau(5, 5);
     var rover = new Rover(new Position(3, 3), "E", plateau);
     _commandProcessorResult = new CommandProcessor().Process(input, rover, plateau);
 }
 public void BecauseOf()
 {
     var input = "1 1 N";
     var plateau = new Plateau(5, 5);
     _commandProcessorResult = new CommandProcessor().Process(input, null, plateau);
 }
Пример #54
0
 public void should_not_validate_rover_as_within_plateau_limits_when_northing_less_than_0()
 {
     var plateau = new Plateau(5, 5);
     var rover = new Rover(3, -4, Direction.South);
     Assert.False(plateau.IsRoverWithinLimits(rover));
 }
Пример #55
0
 public West(Plateau plateau)
 {
     this.plateau = plateau;
 }
Пример #56
0
 public void should_not_validate_rover_as_within_plateau_limits_when_northing_more_than_northboundary()
 {
     var plateau = new Plateau(5, 5);
     var rover = new Rover(3, 7, Direction.West);
     Assert.False(plateau.IsRoverWithinLimits(rover));
 }
Пример #57
0
        public void rover_must_be_placeable(int x, int y)
        {
            var mars = new Plateau(new Size(10, 10));

            Assert.Throws<InvalidOperationException>(() => mars.PlaceRover(new Rover(new Coordinate(x, y), CameraDirection.North)));
        }
Пример #58
0
 public void should_validate_rover_as_within_plateau_limits_when_easting_and_northing_less_than_eastboundary_and_northboundary()
 {
     var plateau = new Plateau(5, 5);
     var rover = new Rover(3, 4, Direction.North);
     Assert.IsTrue(plateau.IsRoverWithinLimits(rover));
 }
 public Tuple<string, Rover, Plateau> Execute(
     string[] commandElements, Rover rover, Plateau plateau)
 {
     return new Tuple<string, Rover, Plateau>("Unknown Command", rover, plateau);
 }
 protected void BecauseOf()
 {
     _plateau = new Plateau(4, 6);
 }