public static void Main() { ListyIterator <string> listyIterator = new ListyIterator <string>(); string command; while ((command = Console.ReadLine()) != "END") { try { var data = command.Split(); switch (data[0]) { case "Create": listyIterator.Create(data.Skip(1).ToArray()); break; case "Move": Console.WriteLine(listyIterator.Move()); break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; case "Print": listyIterator.Print(); break; case "PrintAll": listyIterator.PrintAll(); break; default: break; } } catch (InvalidOperationException ioe) { Console.WriteLine(ioe.Message); } } }
static void Main(string[] args) { ListyIterator <string> iterator = null; string command = null; while ((command = Console.ReadLine()) != "END") { var action = command.Split(); switch (action[0]) { case "Create": iterator = new ListyIterator <string>(action.Skip(1).ToArray()); break; case "Move": Console.WriteLine(iterator.Move()); break; case "Print": Console.WriteLine(iterator.Print()); break; case "HasNext": Console.WriteLine(iterator.HasNext()); break; case "PrintAll": Console.WriteLine(iterator.PrintAll()); break; } } }
public static void Main() { var input = Console.ReadLine() .Split(' ') .Skip(1) .ToList(); var list = new ListyIterator <string>(input); string command; while ((command = Console.ReadLine()) != "END") { try { switch (command) { case "Move": Console.WriteLine(list.Move()); break; case "HasNext": Console.WriteLine(list.HasNext()); break; case "Print": list.Print(); break; case "PrintAll": list.PrintAll(); break; } } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } } }
static void Main(string[] args) { var listyIterator = new ListyIterator <string>(); var input = Console.ReadLine(); var data = input .Split(" ", StringSplitOptions.RemoveEmptyEntries) .Skip(1) .ToList(); listyIterator.Create(data); while ((input = Console.ReadLine()) != "END") { switch (input) { case "Move": Console.WriteLine(listyIterator.Move()); break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; case "Print": listyIterator.Print(); break; case "PrintAll": listyIterator.PrintAll(); break; } } }
static void Main(string[] args) { string input = Console.ReadLine(); string[] tokens = input.Split(); ListyIterator <string> listyIterator = new ListyIterator <string>(tokens.Skip(1).ToList()); while ((input = Console.ReadLine()) != "END") { tokens = input.Split(); switch (tokens[0]) { case ("Move"): { Console.WriteLine(listyIterator.Move()); break; } case ("HasNext"): { Console.WriteLine(listyIterator.HasNext()); break; } case ("Print"): { try { listyIterator.Print(); } catch (ArgumentException e) { Console.WriteLine(e.Message); } break; } case ("PrintAll"): { try { listyIterator.PrintAll(); } catch (ArgumentException e) { Console.WriteLine(e.Message); } break; } } } }
static void Main(string[] args) { string[] data = Console.ReadLine()?.Split(" ", StringSplitOptions.RemoveEmptyEntries) ?? new string[] { }; string[] elements = new string[data.Length - 1]; Array.Copy(data, 1, elements, 0, elements.Length); ListyIterator <string> list = new ListyIterator <string>(elements); string input = Console.ReadLine(); while (input != "END") { try { } catch (Exception e) { Console.WriteLine(e); throw; } switch (input) { case "Move": var result = list.Move(); Console.WriteLine(result); break; case "HasNext": result = list.HasNext(); Console.WriteLine(result); break; case "Print": try { var element = list.Print(); Console.WriteLine(element); } catch (InvalidOperationException exception) { Console.WriteLine(exception.Message); } break; case "PrintAll": var output = list.PrintAll(); Console.WriteLine(output); break; } input = Console.ReadLine(); } }
static void Main(string[] args) { List <string> input = Console.ReadLine() .Split() .Skip(1) .ToList(); ListyIterator <string> list = new ListyIterator <string>(input); string command = Console.ReadLine(); while (command != "END") { switch (command) { case "HasNext": Console.WriteLine(list.HasNext()); break; case "Move": Console.WriteLine(list.Move()); break; case "PrintAll": try { list.PrintAll(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } break; case "Print": try { list.Print(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } break; } command = Console.ReadLine(); } }
static void Main() { string input = Console.ReadLine(); string[] tokens = input.Split(); ListyIterator <string> listyIterator = new ListyIterator <string>(tokens.Skip(1).ToList()); while (input != "END") { tokens = input.Split(); string command = tokens[0]; switch (command) { case "Move": Console.WriteLine(listyIterator.Move()); break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; case "Print": try { listyIterator.Print(); } catch (Exception e) { Console.WriteLine(e.Message); } break; case "PrintAll": try { listyIterator.PrintAll(); } catch (Exception e) { Console.WriteLine(e.Message); } break; } input = Console.ReadLine(); } }
public static void Main(string[] args) { string[] data = Console.ReadLine().Split().Skip(1).ToArray(); ListyIterator <string> list = new ListyIterator <string>(data); string input = Console.ReadLine(); while (input != "END") { switch (input) { case "Move": Console.WriteLine(list.Move()); break; case "Print": try { list.Print(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } break; case "HasNext": Console.WriteLine(list.HasNext()); break; case "PrintAll": try { list.PrintAll(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } break; } input = Console.ReadLine(); } }
static void Main() { string input; while ((input = Console.ReadLine()) != "END") { try { string[] arguments = input.Split(' ', StringSplitOptions.RemoveEmptyEntries); string command = arguments[0]; if (command == "Create") { string[] arr = arguments.Skip(1).ToArray(); store = new ListyIterator <string>(arr); } else if (command == "Print") { store.Print(); } else if (command == "PrintAll") { store.PrintAll(); } else if (command == "HasNext") { Console.WriteLine(store.HasNext()); } else if (command == "Move") { Console.WriteLine(store.Move()); } } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } } }
static void DoCommands(string[] parts, ListyIterator <string> collection) { switch (parts[0]) { case "Create": if (parts.Length == 1) { collection.List = new List <string>(); } else { parts = parts.Skip(1).Take(parts.Length - 1).ToArray(); collection.List = new List <string>(parts); } break; case "Move": Console.WriteLine(collection.Move()); break; case "HasNext": Console.WriteLine(collection.HasNext()); break; case "Print": collection.Print(); break; case "PrintAll": collection.PrintAll(); break; default: break; } }