public void HasDeployedAnExplorer_ExplorerNotLaunched_IsFalse() { IDeploymentZoneChart deploymentZoneChart = new Plateau { Size = new Size(5, 5) }; MissionControlCenter mcc = new MissionControlCenter(deploymentZoneChart); Explorer explorer = new Rover(mcc.Explorers); mcc.Explorers.Add(explorer); Assert.IsFalse(mcc.HasDeployedAnExplorer()); }
public void HasDeployedAnExplorer_ExplorerLaunched_IsTrue() { IDeploymentZoneChart deploymentZoneChart = new Plateau { Size = new Size(5, 5) }; MissionControlCenter mcc = new MissionControlCenter(deploymentZoneChart); Explorer explorer = new Rover(mcc.Explorers); mcc.Explorers.Add(explorer); explorer.Launch(new Position(4, 4), Heading.East); Assert.IsTrue(mcc.HasDeployedAnExplorer()); }
private static void DirectCommandLineInput() { string consoleInput; var commandParser = new CommandParser(); IDeploymentZoneChart deploymentZone = null; do { Console.WriteLine("Enter the size of the deployment zone for your spacecraft: "); consoleInput = Console.ReadLine(); var deploymentZoneCommand = commandParser.ParseCommandBlock(consoleInput); if (deploymentZoneCommand == null || !(deploymentZoneCommand.ToList().First() is DeploymentZoneChartCommand deploymentZoneChartCommand)) { continue; } // Right now, only supporting one type of deployment zone: Plateau. // Definitely room for improvement here to make it more versile with many different kinds of deployment // zones. Adding a factory for this would be good. deploymentZone = new Plateau(); deploymentZoneChartCommand.SetDeploymentZoneChart(deploymentZone); // Set the size of the new deployment zone based on the provided command input. deploymentZoneChartCommand.Execute(); Console.WriteLine("Deployment zone initialized successfully."); } while (deploymentZone == null); Console.WriteLine("Bringing Mission Control Center (MCC) online..."); var mcc = new MissionControlCenter(deploymentZone); Console.WriteLine("MCC Online."); // Must deploy at least one explorer successfully before providing any other commands. Explorer explorer = new Rover(mcc.Explorers); do { Console.WriteLine("Enter deployment coordinates and heading of exploration module: "); consoleInput = Console.ReadLine()?.Trim(); var launchRoverCommand = commandParser.ParseCommandBlock(consoleInput); // Cannot have empty input at this point. if (launchRoverCommand == null || !(launchRoverCommand.ToList().First() is DeployExplorerCommand launchCommand)) { continue; } // Execute the single explorer creation command. launchCommand.SetExplorer(explorer); if (launchCommand.Execute()) { mcc.Explorers.Add(explorer); } } while (!mcc.HasDeployedAnExplorer()); do { Console.WriteLine( "Execute explorer action command by entering string of movement commands, deploy a new rover to " + "provided coordinates and heading, or enter nothing to compose report: "); consoleInput = Console.ReadLine()?.Trim(); var nextCommand = commandParser.ParseCommandBlock(consoleInput); var commandList = nextCommand.ToList(); // User is requesting report due to blank input being provided. if (commandList.Contains(null)) { break; } mcc.SetCommands(commandList); mcc.ExecuteAll(); } while (true); // TODO: Add in report generation capability at any point, not just at the end. Console.WriteLine("Composing exploration report..."); Console.WriteLine(mcc.Explorers.GenerateExplorationReport()); Console.WriteLine("Press any key to exit..."); Console.ReadLine(); }