public void SetValidPlateauSize(int height, int width)
        {
            marsPlateau.SetSize(height, width);

            Assert.Equal(marsPlateau.Size.Height, height);
            Assert.Equal(marsPlateau.Size.Width, width);
        }
        public void LandOnInvalidPosition(int width, int height, CardinalDirections direction)
        {
            var marsPlateau = new MarsPlateau();
            var spaceProbe  = new SpaceProbe();

            marsPlateau.SetSize(1, 1);

            spaceProbe.Land(marsPlateau, new Position(width, height), direction);

            Assert.Null(spaceProbe.Position);
        }
        public void LandOnValidPosition(int width, int height, CardinalDirections direction)
        {
            var marsPlateau = new MarsPlateau();
            var spaceProbe  = new SpaceProbe();

            marsPlateau.SetSize(10, 10);

            spaceProbe.Land(marsPlateau, new Position(width, height), direction);

            Assert.Equal(spaceProbe.Position.XAxis, width);
            Assert.Equal(spaceProbe.Position.YAxis, height);
        }
        public void MoveForward(CardinalDirections direction, int expectedXAxis, int expectedYAxis)
        {
            var spaceProbe = new SpaceProbe();

            spaceProbe.Position  = new Position(2, 2);
            spaceProbe.Direction = direction;

            var marsPlateau = new MarsPlateau();

            marsPlateau.SetSize(3, 3);
            spaceProbe.PlateauLanded = marsPlateau;

            spaceProbe.MoveForward();

            Assert.Equal(spaceProbe.Position.XAxis, expectedXAxis);
            Assert.Equal(spaceProbe.Position.YAxis, expectedYAxis);
        }
Пример #5
0
        public static void Main(string[] args)
        {
            var marsPlateau             = new MarsPlateau();
            List <SpaceProbe> probeList = new List <SpaceProbe>();
            var probe       = new SpaceProbe();
            var consoleRead = "initial";

            while (true)
            {
                consoleRead = Console.ReadLine();

                if (!string.IsNullOrEmpty(consoleRead))
                {
                    var command = new CommandParser(consoleRead);
                    if (command.CommandType == Core.Auxiliar.CommandType.CreatePlateau)
                    {
                        marsPlateau.SetSize(command.Size.Height, command.Size.Width);
                    }
                    else if (command.CommandType == Core.Auxiliar.CommandType.Land)
                    {
                        probe = new SpaceProbe();
                        probeList.Add(probe);
                        probe.Land(marsPlateau, command.Position, command.Direction);
                    }
                    else if (command.CommandType == Core.Auxiliar.CommandType.Move)
                    {
                        probe.Move(command.Movements);
                    }
                }
                else
                {
                    foreach (var item in probeList)
                    {
                        Console.WriteLine(item.Location());
                    }
                }
            }
        }