public static void Main() { string[] array = Console.ReadLine().Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray(); ListIterator listIterator = new ListIterator(array); string input = Console.ReadLine(); while (input != "END") { string[] parts = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); string command = parts[0]; switch (command) { case "Move": Console.WriteLine(listIterator.Move()); break; case "HasNext": Console.WriteLine(listIterator.HasNext()); break; case "Print": Console.WriteLine(listIterator.Print()); break; } input = Console.ReadLine(); } }
static void Main(string[] args) { string command; ListIterator list = new ListIterator(); while ((command = Console.ReadLine()) != "END") { var line = command.Split(); try { switch (line[0]) { case "Create": list.InitialiseList(line.Skip(1).ToArray()); break; case "HasNext": Console.WriteLine(list.HasNext().ToString()); break; case "Move": Console.WriteLine(list.Move().ToString()); break; case "Print": Console.WriteLine(list.Print()); break; } } catch (Exception e) { Console.WriteLine(e.Message); } } }