public string Read() { if (ConsoleReader == null) { throw new InvalidOperationException("Current console has no readable input."); } return(ConsoleReader.Read()); }
static void Main(string[] args) { ConsoleWriter consoleWriter = new ConsoleWriter(); ConsoleReader consoleReader = new ConsoleReader(); consoleWriter.Write("Enter the original path."); string originalPath = consoleReader.Read(); consoleWriter.Write("Enter the copied path."); string copiedPath = consoleReader.Read(); Engine engine = new Engine(consoleWriter, new FileWriter("MissingPaths.txt"), consoleReader, originalPath, copiedPath); try { engine.Start(); } catch (Exception exception) { consoleWriter.Write(exception.Message); } }
public static void Run() { EngineFactory engineFactory = new EngineFactory(); CargoFactory cargoFactory = new CargoFactory(); TireFactory tireFactory = new TireFactory(); CarFactory carFactory = new CarFactory(); ConsoleReader consoleReader = new ConsoleReader(); CarsCatalog cars = new CarsCatalog(engineFactory, cargoFactory, tireFactory, carFactory); int lines = int.Parse(consoleReader.Read()); for (int i = 0; i < lines; i++) { string[] parameters = consoleReader.Read() .Split(" ", StringSplitOptions.RemoveEmptyEntries); cars.Add(parameters); } string command = consoleReader.Read(); cars.GetCarsInfo(command); }
public void Run() { string input = ConsoleReader.Read(); while (true) { if (string.IsNullOrEmpty(input)) { this.EndGame(); return; } ConsoleWriter.Write(commandInterpreter.Interprete(input)); if (this.dungeonMaster.IsGameOver()) { this.EndGame(); return; } input = ConsoleReader.Read(); } }
public void Run() { while (true) { string input = reader.Read(); string output = String.Empty; if (input == "Quit") { break; } string[] commands = input.Split(" ", StringSplitOptions.RemoveEmptyEntries); try { if (commands[0] == "HirePilot") { output = this.manager.HirePilot(commands[1]); } else if (commands[0] == "PilotReport") { output = this.manager.PilotReport(commands[1]); } else if (commands[0] == "ManufactureTank") { output = this.manager.ManufactureTank(commands[1], double.Parse(commands[2]), double.Parse(commands[3])); } else if (commands[0] == "ManufactureFighter") { output = this.manager.ManufactureFighter(commands[1], double.Parse(commands[2]), double.Parse(commands[3])); } else if (commands[0] == "MachineReport") { output = this.manager.MachineReport(commands[1]); } else if (commands[0] == "AggressiveMode") { output = this.manager.ToggleFighterAggressiveMode(commands[1]); } else if (commands[0] == "DefenseMode") { output = this.manager.ToggleTankDefenseMode(commands[1]); } else if (commands[0] == "Engage") { output = this.manager.EngageMachine(commands[1], commands[2]); } else if (commands[0] == "Attack") { output = this.manager.AttackMachines(commands[1], commands[2]); } writer.WriteLine(output); } catch (Exception ex) { writer.WriteLine($"Error: {ex.Message}"); } } }