public static void Main() { var manager = new DraftManager(); var input = Console.ReadLine(); while (input != "Shutdown") { var command = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) .FirstOrDefault(); var commandTokens = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (commandTokens.Count > 1) { commandTokens.Remove(command); } try { switch (command) { case "RegisterHarvester": Console.WriteLine(manager.RegisterHarvester(commandTokens)); break; case "RegisterProvider": Console.WriteLine(manager.RegisterProvider(commandTokens)); break; case "Day": Console.WriteLine(manager.Day()); break; case "Mode": Console.WriteLine(manager.Mode(commandTokens)); break; case "Check": Console.WriteLine(manager.Check(commandTokens)); break; } } catch (Exception ex) { Console.WriteLine(ex.Message); } input = Console.ReadLine(); } Console.WriteLine(manager.ShutDown()); }
static void Main(string[] args) { DraftManager draft = new DraftManager(); while (true) { List <string> arguments = Console.ReadLine() .Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries) .ToList(); if (arguments[0] == "Shutdown") { break; } switch (arguments[0]) { case "RegisterHarvester": { Console.WriteLine(draft.RegisterHarvester(arguments)); } break; case "RegisterProvider": { Console.WriteLine(draft.RegisterProvider(arguments)); } break; case "Day": { Console.WriteLine(draft.Day()); } break; case "Mode": { Console.WriteLine(draft.Mode(arguments)); } break; case "Check": { Console.WriteLine(draft.Check(arguments)); } break; default: break; } } Console.WriteLine(draft.ShutDown()); }
static void Main(string[] args) { var draftManager = new DraftManager(); var input = Console.ReadLine(); while (true) { var inputArgs = input .Split(' ', StringSplitOptions.RemoveEmptyEntries) .ToList(); var command = inputArgs[0]; var arguments = inputArgs.Skip(1).ToList(); switch (command) { case "RegisterHarvester": Console.WriteLine(draftManager.RegisterHarvester(arguments)); break; case "RegisterProvider": Console.WriteLine(draftManager.RegisterProvider(arguments)); break; case "Day": Console.WriteLine(draftManager.Day()); break; case "Mode": Console.WriteLine(draftManager.Mode(arguments)); break; case "Check": Console.WriteLine(draftManager.Check(arguments)); break; case "Shutdown": Console.WriteLine(draftManager.ShutDown()); Environment.Exit(0); break; default: throw new ArgumentException(); } input = Console.ReadLine(); } }
static void Main(string[] args) { var manager = new DraftManager(); while (true) { string[] tokens = Console.ReadLine().Split(); var inputInfo = tokens.Skip(1).ToList(); switch (tokens[0]) { case "RegisterHarvester": Console.WriteLine(manager.RegisterHarvester(inputInfo)); break; case "RegisterProvider": Console.WriteLine(manager.RegisterProvider(inputInfo)); break; case "Day": Console.WriteLine(manager.Day()); break; case "Mode": Console.WriteLine(manager.Mode(inputInfo)); break; case "Check": Console.WriteLine(manager.Check(inputInfo)); break; case "Shutdown": Console.WriteLine(manager.ShutDown()); break; default: throw new NotImplementedException(); } } }
private static void ReadCommands(DraftManager minedraft) { string line; while ((line = Console.ReadLine()) != "Shutdown") { var tokens = line.Split().ToList(); switch (tokens[0]) { case "RegisterHarvester": Console.WriteLine(minedraft.RegisterHarvester(tokens.Skip(1).ToList())); break; case "RegisterProvider": Console.WriteLine(minedraft.RegisterProvider(tokens.Skip(1).ToList())); break; case "Day": Console.WriteLine(minedraft.Day()); break; case "Mode": Console.WriteLine(minedraft.Mode(tokens.Skip(1).ToList())); break; case "Check": Console.WriteLine(minedraft.Check(tokens.Skip(1).ToList())); break; default: break; } } Console.WriteLine(minedraft.ShutDown()); Environment.Exit(0); }
static void Main(string[] args) { var draftManager = new DraftManager(); string command; while ((command = Console.ReadLine()) != "Shutdown") { var tokens = command.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToList(); var currentCommaned = tokens[0]; tokens.RemoveAt(0); var result = string.Empty; switch (currentCommaned) { case "RegisterHarvester": result = draftManager.RegisterHarvester(tokens); break; case "RegisterProvider": result = draftManager.RegisterProvider(tokens); break; case "Day": result = draftManager.Day(); break; case "Mode": result = draftManager.Mode(tokens); break; case "Check": result = draftManager.Check(tokens); break; } Console.WriteLine(result); } Console.WriteLine(draftManager.ShutDown()); }