static void Main(string[] args) { var create = Console.ReadLine().Split().Skip(1).ToArray(); var listy = new ListyIterator <string>(create); while (true) { string command = Console.ReadLine(); switch (command) { case "Move": Console.WriteLine(listy.Move()); break; case "Print": listy.Print(); break; case "HasNext": Console.WriteLine(listy.HasNext()); break; case "PrintAll": foreach (var item in listy) { Console.Write(item + " "); } Console.WriteLine(); break; case "END": return; } } }
public static void Main() { ListyIterator <string> listyIterator = null; string[] command = Console.ReadLine().Split(); while (command[0] != "END") { switch (command[0]) { case "Create": listyIterator = new ListyIterator <string>(command.Skip(1).ToArray()); break; case "Move": Console.WriteLine(listyIterator.Move()); break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; case "Print": Console.WriteLine(listyIterator.Print()); break; case "PrintAll": Console.WriteLine(listyIterator.PrintAll()); break; } command = Console.ReadLine().Split(); } }
public static void Main() { ListyIterator <string> listyIterator = null; while (true) { var inputTokens = Console.ReadLine() .Split(' ', StringSplitOptions.RemoveEmptyEntries); if (inputTokens[0] == "END") { break; } try { listyIterator = ProcessCommand(listyIterator, inputTokens); } catch (Exception e) { Console.WriteLine(e.Message); } } }