static void Main(string[] args) { string comand = Console.ReadLine(); string[] create = comand.Split().Skip(1).ToArray(); ListyIterator <string> list = new ListyIterator <string>(create); while ((comand = Console.ReadLine()) != "END") { if (comand == "Move") { Console.WriteLine(list.Move()); } else if (comand == "HasNext") { Console.WriteLine(list.HasNext()); } else { try { list.Print(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } } } }
static void Main(string[] args) { string[] create = Console.ReadLine().Split(new [] { "Create", " " }, StringSplitOptions.RemoveEmptyEntries); ListyIterator <string> listyIterator = new ListyIterator <string>(create); while (true) { string command = Console.ReadLine(); if (command == "END") { break; } if (command == "HasNext") { bool hasNext = listyIterator.HasNext(); Console.WriteLine(hasNext); } else if (command == "Move") { bool canMove = listyIterator.Move(); Console.WriteLine(canMove); } else if (command == "Print") { listyIterator.Print(); } } }
static void Main() { var elements = Console.ReadLine() .Split(' ') .Skip(1) .ToList(); var listyIterator = new ListyIterator <string>(elements); string command = String.Empty; while ((command = Console.ReadLine()) != "END") { if (command == "Move") { Console.WriteLine(listyIterator.Move()); } else if (command == "HasNext") { Console.WriteLine(listyIterator.HasNext()); } else if (command == "Print") { try { listyIterator.Print(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } } } }
static void Main(string[] args) { string[] createCmd = Console.ReadLine().Split(); string[] elements = createCmd.Skip(1).ToArray(); ListyIterator <string> listyIterator = new ListyIterator <string>(elements); string input; bool result = true; while ((input = Console.ReadLine()) != "END") { if (input == "Print") { listyIterator.Print(); continue; } else if (input == "HasNext") { result = listyIterator.HasNext(); } else if (input == "Move") { result = listyIterator.Move(); } Console.WriteLine(result); } }
static void Main(string[] args) { string[] elements = Console.ReadLine().Split().Skip(1).ToArray(); var listyIterator = new ListyIterator <string>(elements); string command; while ((command = Console.ReadLine()) != "END") { try { switch (command) { case "Move": Console.WriteLine(listyIterator.Move()); break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; case "Print": listyIterator.Print(); break; } } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } } }
static void Main() { var set = new ListyIterator <string>(); while (true) { var input = Console.ReadLine().Split().ToList(); string command = input[0]; if (command == "END") { break; } try { if (command == "Create") { input.RemoveAt(0); set.Create(input); } if (command == "Move") { Console.WriteLine(set.Move()); } if (command == "Print") { Console.WriteLine(set.Print()); } if (command == "PrintAll") { Console.WriteLine(string.Join(' ', set)); } if (command == "HasNext") { Console.WriteLine(set.HasNext()); } } catch (Exception ae) { Console.WriteLine(ae.Message); } } }
private static string CommandsExecution(ListyIterator <string> collection) { var sb = new StringBuilder(); var cmdArgs = Console.ReadLine().Split(); while (cmdArgs[0] != "END") { try { switch (cmdArgs[0]) { case "Move": sb.AppendLine(collection.Move().ToString()); break; case "Print": sb.AppendLine(collection.Print()); break; case "HasNext": sb.AppendLine(collection.HasNext().ToString()); break; case "PrintAll": foreach (var item in collection) { sb.Append($"{item} "); } sb.Remove(sb.Length - 1, 1); sb.AppendLine(); break; default: break; } } catch (ArgumentException ae) { sb.AppendLine(ae.Message); } cmdArgs = Console.ReadLine().Split(); } return(sb.ToString().Trim()); }
static void Main(string[] args) { ListyIterator <string> listyIterator = null; string command; while ((command = Console.ReadLine()) != "END") { var tokens = command.Split(); switch (tokens[0]) { case "Create": listyIterator = new ListyIterator <string>(tokens.Skip(1).ToArray()); break; case "Move": Console.WriteLine(listyIterator.Move()); break; case "Print": try { listyIterator.Print(); } catch (InvalidOperationException ioe) { Console.WriteLine(ioe.Message); } break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; case "PrintAll": foreach (var item in listyIterator) { Console.Write(item + " "); } Console.WriteLine(); break; } } }
public static void Main() { string input; var listyIterator = new ListyIterator <object>(); while ((input = Console.ReadLine()) != "END") { string[] args = input.Split(); string command = args[0]; args = args.Skip(1).ToArray(); switch (command) { case "Create": listyIterator.Create(args); break; case "Move": Console.WriteLine(listyIterator.Move().ToString()); break; case "Print": try { listyIterator.Print(); } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } break; case "HasNext": Console.WriteLine(listyIterator.HasNext().ToString()); break; default: break; } } }
static void Main(string[] args) { string token = Console.ReadLine(); List <string> elements = token .Split(' ', StringSplitOptions.RemoveEmptyEntries) .Skip(1) .ToList(); ListyIterator <string> listyIterator = new ListyIterator <string>(elements); string command = Console.ReadLine(); while (command != "END") { if (command == "Print") { try { listyIterator.Print(); } catch (InvalidOperationException exception) { Console.WriteLine(exception.Message); } } else if (command == "HasNext") { bool result = listyIterator.HasNext(); Console.WriteLine(result); } else if (command == "Move") { bool result = listyIterator.Move(); Console.WriteLine(result); } command = Console.ReadLine(); } }
static void Main(string[] args) { var input = Console.ReadLine(); var listylterator = new ListyIterator <string>(new List <string>()); while (input != "END") { if (input.Contains("Create")) { var createList = input.Split().ToArray(); if (createList.Length > 1) { for (int i = 1; i < createList.Length; i++) { listylterator.coolList.Add(createList[i]); } } } switch (input) { case "Move": Console.WriteLine(listylterator.Move()); break; case "HasNext": Console.WriteLine(listylterator.HasNext()); break; case "Print": Console.WriteLine(listylterator.Print()); break; } input = Console.ReadLine(); } }
static void Main(string[] args) { string[] createCmd = Console.ReadLine().Split(); string[] elements = createCmd.Skip(1).ToArray(); ListyIterator <string> listyIterator = new ListyIterator <string>(elements); string input; while ((input = Console.ReadLine()) != "END") { switch (input) { case "Print": try { listyIterator.Print(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); }; break; case "PrintAll": Console.WriteLine(string.Join(" ", elements)); break; case "Move": Console.WriteLine(listyIterator.Move()); break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; } } }