static void Main(string[] args) { List <string> elements = Console.ReadLine().Split(" ").ToList(); string comand = elements[0]; elements.RemoveAt(0); var list = new ListyIterator <string>(elements.ToArray()); while (comand != "END") { if (comand == "Move") { Console.WriteLine(list.Move()); } else if (comand == "Print") { Console.WriteLine(list.Print()); } else if (comand == "HasNext") { Console.WriteLine(list.HasNext()); } else if (comand == "PrintAll") { list.PrintAll(); } comand = Console.ReadLine(); } }
public static void Main() { var collection = new ListyIterator <string>(); while (true) { var commands = ParseInput(); var firstCommand = commands[0]; commands = commands.Skip(1).ToArray(); if (firstCommand == "END") { break; } try { switch (firstCommand) { case "Create": collection = new ListyIterator <string>(commands); 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; } } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
static void Main(string[] args) { string[] input = Console.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries); ListyIterator <string> listyIterator = new ListyIterator <string>(input.Skip(1).ToArray()); string command = Console.ReadLine(); while (command != "END") { switch (command) { case "Move": Console.WriteLine(listyIterator.Move()); break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; case "Print": try { listyIterator.Print(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } break; case "PrintAll": try { listyIterator.PrintAll(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } break; default: break; } command = Console.ReadLine(); } }
static void Main(string[] args) { ListyIterator <string> listyIterator = null; string cmd = string.Empty; while ((cmd = Console.ReadLine()) != "END") { try { string[] arr = cmd .Split(" ", StringSplitOptions.RemoveEmptyEntries); string command = arr[0]; switch (command) { case "Create": List <string> elements = arr .Skip(1) .ToList(); listyIterator = new ListyIterator <string>(elements); break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; case "Print": listyIterator.Print(); break; case "Move": Console.WriteLine(listyIterator.Move()); break; case "PrintAll": listyIterator.PrintAll(); break; } } catch (Exception e) { Console.WriteLine(e.Message); } } }
public static void Main() { ListyIterator listy = null; string inputInfo; while ((inputInfo = Console.ReadLine()) != "END") { var split = inputInfo.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); try { switch (split[0]) { case "Create": listy = new ListyIterator(split.Skip(1).ToArray()); break; case "Move": Console.WriteLine(listy.Move()); break; case "HasNext": Console.WriteLine(listy.HasNext()); break; case "Print": listy.Print(); break; case "PrintAll": listy.PrintAll(); break; } } catch (Exception) { Console.WriteLine("Invalid Operation!"); } } }