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;
                }

                command = Console.ReadLine().Split();
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = new ListyIterator <string>();

            string input;

            while ((input = Console.ReadLine()) != "END")
            {
                string[] command = input.Split(" ", StringSplitOptions.RemoveEmptyEntries).ToArray();

                switch (command[0])
                {
                case "Create":
                    listyIterator = new ListyIterator <string>(command.Skip(1).ToArray());
                    break;

                case "Move":
                    Console.WriteLine(listyIterator.Move());
                    break;

                case "Print":
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (InvalidOperationException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    break;

                case "HasNext":
                    Console.WriteLine(listyIterator.HasNext());
                    break;
                }
            }
        }
        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);
                }
            }
        }