コード例 #1
0
ファイル: Program.cs プロジェクト: Kersoz/MarsRover
        static void Main(string[] args)
        {
            Console.WriteLine("Please enter the size of your Plateau exp:  5 5");

            //var plateauSize = Console.ReadLine();
            //var size = Validator.ParseCoordinate(plateauSize);

            Plateau plateau = new Plateau(5, 5);


            //Console.WriteLine("Please enter the lcoation of your Rover and Direction exp:  1 2 N");
            //var roverLocation = Console.ReadLine();
            var roverLocation = "3 3 E";

            Rover rover = new Rover(roverLocation, plateau);


            Console.WriteLine("Please enter the movement commands of your Rover");
            //var roverCommands = Console.ReadLine();
            var roverCommands = "MMRMMRMRRM";

            rover.Execute(roverCommands);

            Console.WriteLine(rover.X + " " + rover.Y + " " + rover.Direction);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: cengemrecelik/MarsRover
        static void Main(string[] args)
        {
            Console.WriteLine("Test Input:");
            var upperRight = "5 5";
            //rover1
            var position1 = "1 2 N";
            var command1  = "LMLMLMLMM";
            //rover2
            var position2 = "3 3 E";
            //   var command2 = "MMRMMRMRRM";
            var command2 = "LLLLMR";

            Console.WriteLine(upperRight + "\n" + position1 + "\n" + command1 + "\n" + position2 + "\n" + command2);

            new CoordinateValidation(upperRight).IsValid();
            var upperRightValues = upperRight.Split(" ");
            var plateau          = new Plateau
            {
                Width  = int.Parse(upperRightValues[0]),
                Height = int.Parse(upperRightValues[1]),
                Rovers = new List <Rover>()
            };

            //rover1
            new PositionValidation(position1, plateau.Width, plateau.Height).IsValid();
            var positionValues1 = position1.Split(" ");
            var rover1          = new Rover(int.Parse(positionValues1[0]), int.Parse(positionValues1[1]), (Direction)Enum.Parse(typeof(Direction), positionValues1[2]));

            new CommandValidation(command1).IsValid();
            rover1.Execute(command1, plateau);
            plateau.Rovers.Add(rover1);

            //rover2
            new PositionValidation(position2, plateau.Width, plateau.Height).IsValid();
            var positionValues2 = position2.Split(" ");
            var rover2          = new Rover(int.Parse(positionValues2[0]), int.Parse(positionValues2[1]), (Direction)Enum.Parse(typeof(Direction), positionValues2[2]));

            new CommandValidation(command2).IsValid();
            rover2.Execute(command2, plateau);
            plateau.Rovers.Add(rover2);

            Console.WriteLine("Output:");
            foreach (var item in plateau.Rovers)
            {
                Console.WriteLine(item.PointX + " " + item.PointY + " " + item.Direction);
            }
        }
コード例 #3
0
        public void StayInTheSamePositionGivenNoCommands()
        {
            var position = _rover.Execute(string.Empty);

            Assert.Equal("0:0:N", position);
        }
コード例 #4
0
ファイル: MarsRoverShould.cs プロジェクト: Arkimbauer/cokaido
        public void MoveDoubleStepsWhenRoverHasBoostedMovement()
        {
            var position = _boostedRover.Execute("M");

            Assert.Equal("0:2:N", position);
        }