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);
        }
Exemplo n.º 3
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());
                    }
                }
            }
        }