public void Run() { IMachinesManager machinesManager = new MachinesManager(); var inputCommand = Console.ReadLine(); try { while (inputCommand != "Quit") { var inputCommandList = inputCommand.Split(new string[] { " " }, StringSplitOptions.None).ToList(); switch (inputCommandList[0]) { case "HirePilot": Write(machinesManager.HirePilot(inputCommandList[1])); break; case "PilotReport": Write(machinesManager.PilotReport(inputCommandList[1])); break; case "ManufactureTank": Write(machinesManager.ManufactureTank(inputCommandList[1], double.Parse(inputCommandList[2]), double.Parse(inputCommandList[3]))); break; case "ManufactureFighter": Write(machinesManager.ManufactureFighter(inputCommandList[1], double.Parse(inputCommandList[2]), double.Parse(inputCommandList[3]))); break; case "MachineReport": Write(machinesManager.MachineReport(inputCommandList[1])); break; case "AggressiveMode": Write(machinesManager.ToggleFighterAggressiveMode(inputCommandList[1])); break; case "DefenseMode": Write(machinesManager.ToggleTankDefenseMode(inputCommandList[1])); break; case "Engage": Write(machinesManager.EngageMachine(inputCommandList[1], inputCommandList[2])); break; case "Attack": Write(machinesManager.AttackMachines(inputCommandList[1], inputCommandList[2])); break; } inputCommand = Console.ReadLine(); } } catch (Exception ex) { Console.WriteLine($"Error:{ex.Message}"); } }
public void Run() { var manager = new MachinesManager(); var writer = new Writer(); string input = Console.ReadLine(); try { while (input != "Quit") { string[] tokens = input.Split(); if (tokens[0] == "HirePilot") { writer.Write(manager.HirePilot(tokens[1])); } else if (tokens[0] == "PilotReport") { writer.Write(manager.PilotReport(tokens[1])); } else if (tokens[0] == "ManufactureTank") { writer.Write(manager.ManufactureTank(tokens[1], double.Parse(tokens[2]), double.Parse(tokens[3]))); } else if (tokens[0] == "ManufactureFighter") { writer.Write(manager.ManufactureFighter(tokens[1], double.Parse(tokens[2]), double.Parse(tokens[3]))); } else if (tokens[0] == "MachineReport") { writer.Write(manager.MachineReport(tokens[1])); } else if (tokens[0] == "AggressiveMode") { writer.Write(manager.ToggleFighterAggressiveMode(tokens[1])); } else if (tokens[0] == "DefenseMode") { writer.Write(manager.ToggleTankDefenseMode(tokens[1])); } else if (tokens[0] == "Engage") { writer.Write(manager.EngageMachine(tokens[1], tokens[2])); } else if (tokens[0] == "Attack") { writer.Write(manager.AttackMachines(tokens[1], tokens[2])); } input = Console.ReadLine(); } } catch (Exception ex) { writer.Write("Error: " + ex.Message); } }
public void Run() { var manager = new MachinesManager(); while (true) { string input = Console.ReadLine(); if (input == "Quit") { break; } var commandParts = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string command = commandParts[0]; string s = string.Empty; try { switch (command) { case "HirePilot": s = manager.HirePilot(commandParts[1]); break; case "PilotReport": s = manager.PilotReport(commandParts[1]); break; case "ManufactureTank": s = manager.ManufactureTank(commandParts[1], double.Parse(commandParts[2]), double.Parse(commandParts[3])); break; case "ManufactureFighter": s = manager.ManufactureFighter(commandParts[1], double.Parse(commandParts[2]), double.Parse(commandParts[3])); break; case "MachineReport": s = manager.MachineReport(commandParts[1]); break; case "AggressiveMode": s = manager.ToggleFighterAggressiveMode(commandParts[1]); break; case "DefenseMode": s = manager.ToggleTankDefenseMode(commandParts[1]); break; case "Engage": s = manager.EngageMachine(commandParts[1], commandParts[2]); break; case "Attack": s = manager.AttackMachines(commandParts[1], commandParts[2]); break; } Console.WriteLine(s); } catch (Exception e) { Console.WriteLine($"Error: {e.Message}"); } } }
public void Run() { MachinesManager machinesManager = new MachinesManager(); while (true) { string input = Console.ReadLine(); string[] splitedInput = input.Split(); string command = splitedInput[0]; if (command == "Quit") { break; } if (command == "HirePilot") { string name = splitedInput[1]; Console.WriteLine(machinesManager.HirePilot(name)); } else if (command == "PilotReport") { string name = splitedInput[1]; Console.WriteLine(machinesManager.PilotReport(name)); } else if (command == "ManufactureTank") { string name = splitedInput[1]; double attack = double.Parse(splitedInput[2]); double defense = double.Parse(splitedInput[3]); Console.WriteLine(machinesManager.ManufactureTank(name, attack, defense)); } else if (command == "ManufactureFighter") { string name = splitedInput[1]; double attack = double.Parse(splitedInput[2]); double defense = double.Parse(splitedInput[3]); Console.WriteLine(machinesManager.ManufactureFighter(name, attack, defense)); } else if (command == "MachineReport") { string name = splitedInput[1]; Console.WriteLine(machinesManager.MachineReport(name)); } else if (command == "AggressiveMode") { string name = splitedInput[1]; Console.WriteLine(machinesManager.ToggleFighterAggressiveMode(name)); } else if (command == "DefenseMode") { string name = splitedInput[1]; Console.WriteLine(machinesManager.ToggleTankDefenseMode(name)); } else if (command == "Engage") { string pilotName = splitedInput[1]; string machineName = splitedInput[2]; Console.WriteLine(machinesManager.EngageMachine(pilotName, machineName)); } else if (command == "Attack") { string attackingMachineName = splitedInput[1]; string defensingMachineName = splitedInput[2]; Console.WriteLine(machinesManager.AttackMachines(attackingMachineName, defensingMachineName)); } } }
public CommandInterpreter() { this.machinesManager = new MachinesManager(); }
public void Run() { var input = string.Empty; try { var machineManager = new MachinesManager(); while ((input = Console.ReadLine()) != "Quit") { var arguments = input.Split(" ", StringSplitOptions.RemoveEmptyEntries); if (input.ToLower().StartsWith("hirepilot")) { var name = arguments[1]; Console.WriteLine(machineManager.HirePilot(name)); } else if (input.ToLower().StartsWith("pilotreport")) { var name = arguments[1]; Console.WriteLine(machineManager.PilotReport(name)); } else if (input.ToLower().StartsWith("manufacturetank")) { var name = arguments[1]; var attack = double.Parse(arguments[2]); var defense = double.Parse(arguments[3]); Console.WriteLine(machineManager.ManufactureTank(name, attack, defense)); } else if (input.ToLower().StartsWith("manufacturefighter")) { var name = arguments[1]; var attack = double.Parse(arguments[2]); var defense = double.Parse(arguments[3]); Console.WriteLine(machineManager.ManufactureFighter(name, attack, defense)); } else if (input.ToLower().StartsWith("machinereport")) { var name = arguments[1]; Console.WriteLine(machineManager.MachineReport(name)); } else if (input.ToLower().StartsWith("aggressivemode")) { var name = arguments[1]; Console.WriteLine(machineManager.ToggleFighterAggressiveMode(name)); } else if (input.ToLower().StartsWith("defensemode")) { var name = arguments[1]; Console.WriteLine(machineManager.ToggleTankDefenseMode(name)); } else if (input.ToLower().StartsWith("engage")) { var pilotName = arguments[1]; var machineName = arguments[2]; Console.WriteLine(machineManager.EngageMachine(pilotName, machineName)); } else if (input.ToLower().StartsWith("attack")) { var attackMachineName = arguments[1]; var defenceMachineName = arguments[2]; Console.WriteLine(machineManager.AttackMachines(attackMachineName, defenceMachineName)); } } } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } }
public Engine() { this.manager = new MachinesManager(); this.reader = new Reader(); this.writer = new Writer(); }
public void Run() { var machinesMenager = new MachinesManager(); string command = null; while ((command = Console.ReadLine()) != "Quit") { var cmdArgs = command.Split(); var operation = cmdArgs[0]; var name = cmdArgs[1]; var commandMachineManager = string.Empty; try { if (operation == "HirePilot") { commandMachineManager = machinesMenager.HirePilot(name); } else if (operation == "PilotReport") { commandMachineManager = machinesMenager.PilotReport(name); } else if (operation == "ManufactureTank") { var attack = double.Parse(cmdArgs[2]); var defence = double.Parse(cmdArgs[3]); commandMachineManager = machinesMenager.ManufactureTank(name, attack, defence); } else if (operation == "ManufactureFighter") { var attack = double.Parse(cmdArgs[2]); var defence = double.Parse(cmdArgs[3]); commandMachineManager = machinesMenager.ManufactureFighter(name, attack, defence); } else if (operation == "MachineReport") { commandMachineManager = machinesMenager.MachineReport(name); } else if (operation == "AggressiveMode") { commandMachineManager = machinesMenager.ToggleFighterAggressiveMode(name); } else if (operation == "DefenseMode") { commandMachineManager = machinesMenager.ToggleTankDefenseMode(name); } else if (operation == "Engage") { var machineName = cmdArgs[2]; commandMachineManager = machinesMenager.EngageMachine(name, machineName); } else if (operation == "Attack") { var deffMachineName = cmdArgs[2]; commandMachineManager = machinesMenager.AttackMachines(name, deffMachineName); } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.WriteLine(commandMachineManager); } }
public Engine() { machineManager = new MachinesManager(); }
public Engine() { this.machinesManager = new MachinesManager(); this.commandInterpreter = new CommandInterpreter(); this.consoleWriter = new ConsoleWriter(); }
public void Run() { MachinesManager manager = new MachinesManager(); string line = Console.ReadLine(); while (line != "Quit") { string[] items = line.Split(); string result = string.Empty; try { switch (items[0]) { case "HirePilot": result = manager.HirePilot(items[1]); break; case "PilotReport": result = manager.PilotReport(items[1]); break; case "ManufactureTank": result = manager.ManufactureTank(items[1], double.Parse(items[2]), double.Parse(items[3])); break; case "ManufactureFighter": result = manager.ManufactureFighter(items[1], double.Parse(items[2]), double.Parse(items[3])); break; case "MachineReport": result = manager.MachineReport(items[1]); break; case "AggressiveMode": result = manager.ToggleFighterAggressiveMode(items[1]); break; case "DefenseMode": result = manager.ToggleTankDefenseMode(items[1]); break; case "Engage": result = manager.EngageMachine(items[1], items[2]); break; case "Attack": result = manager.AttackMachines(items[1], items[2]); break; default: break; } } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } Console.WriteLine(result); line = Console.ReadLine(); } }
public void Run() { var input = Console.ReadLine(); manager = new MachinesManager(); while (input != "Quit") { var command = input? .Split(); if (command?[0] == "HirePilot") { Console.WriteLine(manager.HirePilot(command[1])); } else if (command?[0] == "PilotReport") { Console.WriteLine(manager.PilotReport(command[1])); } else if (command?[0] == "ManufactureTank") { Console.WriteLine(manager .ManufactureTank(command[1], double.Parse(command[2]), double.Parse(command[3]))); } else if (command?[0] == "ManufactureFighter") { Console.WriteLine(manager .ManufactureFighter(command[1], double.Parse(command[2]), double.Parse(command[3]))); } else if (command?[0] == "MachineReport") { Console.WriteLine(manager .MachineReport(command[1])); } else if (command?[0] == "AggressiveMode") { Console.WriteLine(manager .ToggleFighterAggressiveMode(command[1])); } else if (command?[0] == "DefenseMode") { Console.WriteLine(manager .ToggleTankDefenseMode(command[1])); } else if (command?[0] == "Engage") { Console.WriteLine(manager .EngageMachine(command[1] , command[2])); } else if (command?[0] == "Attack") { Console.WriteLine(manager .AttackMachines(command[1] , command[2])); } input = Console.ReadLine(); } }
public Engine(MachinesManager mg) { this.mg = mg; }
public void Run() { IMachinesManager manager = new MachinesManager(); while (true) { string input = Console.ReadLine(); if (input == "Quit") { break; } string[] commandArgs = input.Split(); string command = commandArgs[0]; string result = string.Empty; try { switch (command) { case "HirePilot": result = manager.HirePilot(commandArgs[1]); break; case "PilotReport": result = manager.PilotReport(commandArgs[1]); break; case "ManufactureTank": result = manager.ManufactureTank(commandArgs[1], double.Parse(commandArgs[2]), double.Parse(commandArgs[3])); break; case "ManufactureFighter": result = manager.ManufactureFighter(commandArgs[1], double.Parse(commandArgs[2]), double.Parse(commandArgs[3])); break; case "MachineReport": result = manager.MachineReport(commandArgs[1]); break; case "AggressiveMode": result = manager.ToggleFighterAggressiveMode(commandArgs[1]); break; case "DefenseMode": result = manager.ToggleTankDefenseMode(commandArgs[1]); break; case "Engage": result = manager.EngageMachine(commandArgs[1], commandArgs[2]); break; case "Attack": result = manager.AttackMachines(commandArgs[1], commandArgs[2]); break; default: break; } } catch (Exception ex) { Console.WriteLine($"Error: {ex.Message}"); } Console.WriteLine(result); } }
public void Run() { var machineManager = new MachinesManager(); var input = Console.ReadLine(); while (input != "Quit") { var inputArgs = input.Split(" ", StringSplitOptions.RemoveEmptyEntries); var command = inputArgs[0]; var args = inputArgs.Skip(1).ToArray(); var result = string.Empty; try { switch (command) { case "HirePilot": result = machineManager.HirePilot(args[0]); break; case "PilotReport": result = machineManager.PilotReport(args[0]); break; case "ManufactureTank": result = machineManager.ManufactureTank(args[0], double.Parse(args[1]), double.Parse(args[2])); break; case "ManufactureFighter": result = machineManager.ManufactureFighter(args[0], double.Parse(args[1]), double.Parse(args[2])); break; case "MachineReport": result = machineManager.MachineReport(args[0]); break; case "AggressiveMode": result = machineManager.ToggleFighterAggressiveMode(args[0]); break; case "DefenseMode": result = machineManager.ToggleTankDefenseMode(args[0]); break; case "Engage": result = machineManager.EngageMachine(args[0], args[1]); break; case "Attack": result = machineManager.AttackMachines(args[0], args[1]); break; } Console.WriteLine(result); } catch (Exception ex) { Console.WriteLine("Error:" + ex.Message); } input = Console.ReadLine(); } }
public void Run() { var machinesManager = new MachinesManager(); var writer = new Writer(); string command = Console.ReadLine(); try { while (command != "Quit") { if (command.StartsWith("HirePilot")) { string[] name = command.Split().Skip(1).ToArray(); writer.Write(machinesManager.HirePilot(name[0])); } else if (command.StartsWith("PilotReport")) { string[] name = command.Split().Skip(1).ToArray(); writer.Write(machinesManager.PilotReport(name[0])); } else if (command.StartsWith("ManufactureTank")) { string[] info = command.Split(); string name = info[1]; double attack = double.Parse(info[2]); double defense = double.Parse(info[3]); writer.Write(machinesManager.ManufactureTank(name, attack, defense)); } else if (command.StartsWith("ManufactureFighter")) { string[] info = command.Split(); string name = info[1]; double attack = double.Parse(info[2]); double defense = double.Parse(info[3]); writer.Write(machinesManager.ManufactureFighter(name, attack, defense)); } else if (command.StartsWith("MachineReport")) { string[] name = command.Split().Skip(1).ToArray(); writer.Write(machinesManager.MachineReport(name[0])); } else if (command.StartsWith("AggressiveMode")) { string[] name = command.Split().Skip(1).ToArray(); writer.Write(machinesManager.ToggleFighterAggressiveMode(name[0])); } else if (command.StartsWith("DefenseMode")) { string[] name = command.Split().Skip(1).ToArray(); writer.Write(machinesManager.ToggleTankDefenseMode(name[0])); } else if (command.StartsWith("Engage")) { string[] info = command.Split(); string pilotName = info[1]; string machineName = info[2]; writer.Write(machinesManager.EngageMachine(pilotName, machineName)); } else if (command.StartsWith("Attack")) { string[] info = command.Split(); string attackingMachineName = info[1]; string defendingMachineName = info[2]; writer.Write(machinesManager.AttackMachines(attackingMachineName, defendingMachineName)); } command = Console.ReadLine(); } } catch (Exception ex) { writer.Write($"Error:{ex.Message}"); } }
public Engine() { this.machinesManager = new MachinesManager(); }
public void Run() { string input = Console.ReadLine(); IMachinesManager machinesManager = new MachinesManager(); var message = string.Empty; while (input != "Quit") { var args = input.Split(" "); try { switch (args[0]) { case "HirePilot": message = machinesManager.HirePilot(args[1]); Console.WriteLine(message); break; case "PilotReport": message = machinesManager.PilotReport(args[1]); Console.WriteLine(message); break; case "ManufactureTank": message = machinesManager.ManufactureTank(args[1], double.Parse(args[2]), double.Parse(args[3])); Console.WriteLine(message); break; case "ManufactureFighter": message = machinesManager.ManufactureFighter(args[1], double.Parse(args[2]), double.Parse(args[3])); Console.WriteLine(message); break; case "MachineReport": message = machinesManager.MachineReport(args[1]); Console.WriteLine(message); break; case "AggressiveMode": message = machinesManager.ToggleFighterAggressiveMode(args[1]); Console.WriteLine(message); break; case "DefenseMode": message = machinesManager.ToggleTankDefenseMode(args[1]); Console.WriteLine(message); break; case "Engage": message = machinesManager.EngageMachine(args[1], args[2]); Console.WriteLine(message); break; case "Attack": message = machinesManager.AttackMachines(args[1], args[2]); Console.WriteLine(message); break; } } catch (Exception ex) { Console.WriteLine($"Error:{ex.InnerException.Message}"); } input = Console.ReadLine(); } }