public static void Main() { List <string> createCommand = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList(); ListyIterator <string> list = new ListyIterator <string>(createCommand.GetRange(1, createCommand.Count - 1)); string input = Console.ReadLine(); while (input != "END") { switch (input) { case "Move": Console.WriteLine(list.Move()); break; case "HasNext": Console.WriteLine(list.HasNext()); break; case "Print": list.Print(); break; case "PrintAll": list.PrintAll(); break; default: break; } input = Console.ReadLine(); } }
static void Main(string[] args) { string[] createCommandItems = Console.ReadLine() .Split() .Skip(1) .ToArray(); ListyIterator <string> list = new ListyIterator <string>(createCommandItems); string command = Console.ReadLine(); while (command != "END") { switch (command) { case "Move": Console.WriteLine(list.Move()); break; case "Print": list.Print(); break; case "HasNext": Console.WriteLine(list.HasNext()); break; case "PrintAll": list.PrintAll(); break; } command = Console.ReadLine(); } }
static void Main(string[] args) { string command = Console.ReadLine(); List <string> elements = command .Split() .Skip(1) .ToList(); ListyIterator <string> listyIterator = new ListyIterator <string>(elements); command = Console.ReadLine(); while (true) { if (command == "END") { break; } else { if (command == "Print") { try { listyIterator.Print(); } catch (Exception) { Console.WriteLine("Invalid operation!"); } } else if (command == "Move") { bool result = listyIterator.Move(); Console.WriteLine(result); } else if (command == "HasNext") { bool hasNext = listyIterator.HasNext(); Console.WriteLine(hasNext); } else if (command == "PrintAll") { foreach (var item in listyIterator) { Console.Write($"{item} "); } Console.WriteLine(); } command = Console.ReadLine(); } } }
static void Main(string[] args) { string input = Console.ReadLine(); ListyIterator <string> collection = new ListyIterator <string>(); while (input != "END") { string[] tokens = input.Split(); string command = tokens[0].ToLower(); switch (command) { case "create": List <string> nameCollection = new List <string>(); for (int i = 1; i < tokens.Length; i++) { nameCollection.Add(tokens[i]); } collection.Create(nameCollection); break; case "move": Console.WriteLine(collection.Move()); break; case "hasnext": Console.WriteLine(collection.HasNext()); break; case "print": try { collection.Print(); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; case "printall": try { collection.PrintAll(); } catch (Exception ex) { Console.WriteLine(ex.Message); } break; default: break; } input = Console.ReadLine(); } }
public static void Main() { var create = Console.ReadLine().Split(); var elements = create.Skip(1).Take(create.Length - 1).ToList(); var listyIterator = new ListyIterator <string>(elements); while (true) { var command = Console.ReadLine(); if (command == "END") { break; } 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 { Console.WriteLine(string.Join(" ", listyIterator)); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } break; } } }
public static void Main(string[] args) { string[] listElements = Console.ReadLine() .Split() .Skip(1) .ToArray(); ListyIterator <string> iterator = new ListyIterator <string>(listElements); string command = string.Empty; while ((command = Console.ReadLine()) != "END") { switch (command) { case "HasNext": Console.WriteLine(iterator.HasNext()); break; case "Move": Console.WriteLine(iterator.Move()); break; case "Print": try { iterator.Print(); } catch (InvalidOperationException e) { Console.WriteLine(e.Message); } break; case "PrintAll": StringBuilder sb = new StringBuilder(); foreach (var item in iterator) { sb.Append(item + " "); } string result = sb.ToString().TrimEnd(); Console.WriteLine(result); break; default: break; } } }
static void Main(string[] args) { string[] create = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries) .Skip(1) .ToArray(); ListyIterator <string> iterator = new ListyIterator <string>(create); string cmd = Console.ReadLine(); while (cmd != "END") { switch (cmd) { case "HasNext": Console.WriteLine(iterator.HasNext()); break; case "Move": Console.WriteLine(iterator.Move()); break; case "Print": try { iterator.Print(); } catch (InvalidOperationException) { Console.WriteLine("Invalid Operation!"); } break; case "PrintAll": foreach (string s in iterator) { Console.Write($"{s} "); } Console.WriteLine(); break; default: break; } cmd = Console.ReadLine(); } }
static void Main(string[] args) { var collection = new ListyIterator <string>(); string input; while ((input = Console.ReadLine()) != "END") { var command = input.Split().ToArray(); try { switch (command[0]) { case "Create": var elements = command.Skip(1).ToArray(); collection = new ListyIterator <string>(elements); break; case "Move": Console.WriteLine(collection.Move()); break; case "HasNext": Console.WriteLine(collection.HasNext()); break; case "Print": collection.Print(); break; case "PrintAll": foreach (var item in collection) { Console.Write(item + " "); } Console.WriteLine(); break; } } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } } }
static void Main(string[] args) { ListyIterator <string> collection = null; string line; while ((line = Console.ReadLine()) != "END") { try { var tokens = line.Split().ToList(); var command = tokens[0]; tokens = tokens.Skip(1).ToList(); switch (command) { case "Create": collection = new ListyIterator <string>(tokens); break; case "Move": Console.WriteLine(collection.Move()); break; case "Print": collection.Print(); break; case "HasNext": Console.WriteLine(collection.HasNext()); break; case "PrintAll": var result = string.Empty; foreach (var item in collection) { result += item + " "; } Console.WriteLine(result); break; } } catch (ArgumentException err) { Console.WriteLine(err.Message); } } }
static void Main(string[] args) { ListyIterator <string> listyIterator = null; string command = string.Empty; while ((command = Console.ReadLine()) != "END") { string[] elements = command .Split(" ", StringSplitOptions.RemoveEmptyEntries); switch (elements[0]) { case "Create": listyIterator = new ListyIterator <string>(elements.Skip(1).ToArray()); break; case "Move": Console.WriteLine(listyIterator.Move()); break; case "Print": try { listyIterator.Print(); } catch (ArgumentException ae) { Console.WriteLine(ae.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() { var createCmd = Console.ReadLine().Split().ToList(); var elements = createCmd.Skip(1).ToList(); ListyIterator <string> listIterator = new ListyIterator <string>(elements); var cmd = Console.ReadLine(); while (cmd != "END") { switch (cmd) { case "HasNext": Console.WriteLine(listIterator.HasNext()); break; case "Move": Console.WriteLine(listIterator.Move()); break; case "Print": try { Console.WriteLine(listIterator.Print()); } catch (InvalidOperationException e) { Console.WriteLine(e.Message); } break; case "PrintAll": try { Console.WriteLine(listIterator.PrintAll()); } catch (InvalidOperationException e) { Console.WriteLine(e.Message); } break; } cmd = Console.ReadLine(); } }
static void Main(string[] args) { string input = Console.ReadLine(); ListyIterator <string> listyIterator = new ListyIterator <string>( input.Split(" ", StringSplitOptions.RemoveEmptyEntries).Skip(1).ToList()); input = Console.ReadLine(); while (input != "END") { string[] tokens = input.Split(" ", StringSplitOptions.RemoveEmptyEntries); string command = tokens[0]; try { switch (command) { 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); } input = Console.ReadLine(); } }
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() { var command = Console.ReadLine(); var list = command.Split().ToList(); list.RemoveAt(0); ListyIterator <string> listy = new ListyIterator <string>(list); while (!command.Equals("END")) { try { switch (command) { case "Print": listy.Print(); break; case "Move": Console.WriteLine(listy.Move()); break; case "HasNext": Console.WriteLine(listy.HasNext()); break; case "PrintAll": var sb = new StringBuilder(); foreach (var item in listy) { sb.Append($"{item} "); } sb.Remove(sb.Length - 1, 1); Console.WriteLine(sb); break; } } catch (ArgumentException arg) { Console.WriteLine(arg.Message); } command = Console.ReadLine(); } }
static void Main(string[] args) { string input; ListyIterator <string> listyIterator = null; while ((input = Console.ReadLine()) != "END") { var cmdArgs = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); var command = cmdArgs[0]; switch (command) { case "Create": var elements = cmdArgs.Skip(1).ToArray(); listyIterator = new ListyIterator <string>(elements); break; case "Move": Console.WriteLine(listyIterator.Move()); break; case "Print": try { Console.WriteLine(listyIterator.Print()); } catch (Exception e) { Console.WriteLine(e.Message); } break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; case "PrintAll": Console.WriteLine(listyIterator.PrintAll()); break; } } }
public static void Main() { var inputCommand = Console.ReadLine(); var listyIterator = new ListyIterator <string>(inputCommand.Split(' ').Skip(1)); while ((inputCommand = Console.ReadLine()).ToLower() != "end") { var tokens = inputCommand.Split(' '); switch (tokens[0]) { 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": Console.WriteLine(string.Join(" ", listyIterator)); //foreach (var element in listyIterator) //{ // Console.Write($"{element} "); //} //Console.WriteLine(); break; } } }
public static void Main() { var createCommand = Console.ReadLine().Split().ToList(); createCommand.RemoveAt(0); var iterator = new ListyIterator <string>(createCommand); var command = Console.ReadLine(); while (command != "END") { try { switch (command) { case "Move": Console.WriteLine(iterator.Move()); break; case "HasNext": Console.WriteLine(iterator.HasNext()); break; case "Print": iterator.Print(); break; case "PrintAll": iterator.PrintAll(); break; } } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } command = Console.ReadLine(); } }
static void Main(string[] args) { List <string> rawElements = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList(); rawElements.RemoveAt(0); if (rawElements.Count == 0) { rawElements = null; } ListyIterator <string> listyIterator = new ListyIterator <string>(rawElements); string input = Console.ReadLine(); while (input != "END") { string[] command = input.Split(" ", StringSplitOptions.RemoveEmptyEntries); switch (command[0]) { 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; } input = Console.ReadLine(); } }
public static void Main() { string[] input = Console.ReadLine().Split(' ').Skip(1).ToArray(); ListyIterator <string> collection = new ListyIterator <string>(input); string command = Console.ReadLine(); while (command != "END") { switch (command) { case "HasNext": Console.WriteLine(collection.HasNext()); break; case "Move": Console.WriteLine(collection.Move()); break; case "Print": collection.Print(); break; case "PrintAll": var result = new StringBuilder(); foreach (var element in collection) { result.Append(element + " "); } Console.WriteLine(result.ToString().Trim()); break; } command = Console.ReadLine(); } }
public static void Main() { List <string> createCommand = Console.ReadLine() .Split(" ", StringSplitOptions.RemoveEmptyEntries) .Skip(1) .ToList(); ListyIterator <string> listyIterator = new ListyIterator <string>(createCommand); 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": listyIterator.Print(); break; case "PrintAll": foreach (var item in listyIterator) { Console.Write(item + " "); } Console.WriteLine(); break; } command = Console.ReadLine(); } }
public static void Main() { var data = new ListyIterator <string>(); while (true) { var input = Console.ReadLine(); if (input == "END") { break; } if (input.Contains("Create")) { data.Create(input.Split(" ", StringSplitOptions.RemoveEmptyEntries)); } else { switch (input) { case "Move": Console.WriteLine(data.Move()); break; case "HasNext": Console.WriteLine(data.HasNext()); break; case "Print": data.Print(); break; case "PrintAll": Console.WriteLine(string.Join(" ", data)); break; } } } }
static void Main( ) { ListyIterator <string> listyIterator = new ListyIterator <string>(); string input; while ((input = Console.ReadLine()) != "END") { var args = input.Split(); var cmd = args[0]; switch (cmd) { case "Create": listyIterator.Create(args.Skip(1).ToArray()); break; case "HasNext": Console.WriteLine(listyIterator.HasNext()); break; case "Move": Console.WriteLine(listyIterator.Move()); break; case "Print": listyIterator.Print(); break; case "PrintAll": listyIterator.PrintAll(); break; default: break; } } }
static void Main(string[] args) { var input = Console.ReadLine(); var listItems = input.Split().Skip(1).ToArray(); var collection = new ListyIterator <string>(listItems); while ((input = Console.ReadLine()) != "END") { try { switch (input) { case "HasNext": Console.WriteLine(collection.HasNext()); break; case "Move": Console.WriteLine(collection.Move()); break; case "Print": collection.Print(); break; case "PrintAll": collection.PrintAll(); break; default: break; } } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } } }
static void Main(string[] args) { List <string> items = Console.ReadLine().Split().Skip(1).ToList(); ListyIterator <string> list = new ListyIterator <string>(items); string command = Console.ReadLine(); while (command != "END") { switch (command) { case "Move": Console.WriteLine(list.Move()); break; case "HasNext": Console.WriteLine(list.HasNext()); break; case "Print": try { list.Print(); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } break; case "PrintAll": Console.WriteLine(string.Join(" ", list)); break; } command = Console.ReadLine(); } }
static void Main(string[] args) { var tokens = Console.ReadLine().Split(); ListyIterator <string> iterator = new ListyIterator <string>(tokens.Skip(1).ToArray()); string input; while ((input = Console.ReadLine()) != "END") { switch (input) { case "Move": bool isMoved = iterator.Move(); iterator.Print(isMoved); break; case "PrintAll": iterator.PrintAll(); break; case "HasNext": bool next = iterator.HasNext(); iterator.Print(next); break; case "Print": try { iterator.Print(); } catch (Exception e) { Console.WriteLine(e.Message); } break; } } }
static void Main() { var input = Console.ReadLine(); ListyIterator <string> iterator = null; while (input != "END") { var tokens = input.Split(' ').ToList(); switch (tokens[0]) { case "Create": iterator = new ListyIterator <string>(new List <string>(tokens.Skip(1))); break; case "HasNext": Console.WriteLine(iterator.HasNext()); break; case "Move": Console.WriteLine(iterator.Move()); break; case "Print": iterator.Print(); break; case "PrintAll": iterator.PrintAll(); break; default: break; } input = Console.ReadLine(); } }