static void Main(string[] args) { var services = new ServiceCollection(); services.AddSingleton <ISpaceCompany, Nasa>(); var serviceProvider = services.BuildServiceProvider(); //Create space company var spaceCompany = serviceProvider.GetService <ISpaceCompany>(); //Set plateau upper border Plateau.SetUpperCoordinate(5, 5); var position1 = new Position(1, 2, Direction.N); var position2 = new Position(3, 3, Direction.E); //Create rovers var rover1 = new Rover(position1); var rover2 = new Rover(position2); //Create messages var message1 = new Message("LMLMLMLMM"); var message2 = new Message("MMRMMRMRRM"); //Company start to listen for rover final position spaceCompany.Subscribe(rover1); spaceCompany.Subscribe(rover2); //Rover start to move with inputs rover1.Move(message1); rover2.Move(message2); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("***Mars Rover App*****"); Console.WriteLine(); Console.WriteLine("Plateau 5 5"); Console.WriteLine("Rover Position 1 2 N"); Console.WriteLine("input: LMLMLMLMM"); Console.WriteLine(); Console.WriteLine("Expected Output:1 3 N"); Console.WriteLine("MMRMMRMRRM"); Console.WriteLine(); Plateau plateau = new Plateau(new Position(5, 5)); Rover rover = new Rover(plateau, new Position(1, 2), Direction.N); rover.Run("LMLMLMLMM"); Console.WriteLine(); Console.WriteLine("Output " + rover.LastRoverPosition()); Console.WriteLine(); Console.ReadLine(); }