예제 #1
0
        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 "HasNext":
                    bool next = iterator.HasNext();
                    iterator.Print(next);
                    break;

                case "Print":
                    try
                    {
                        iterator.Print();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    break;
                }
            }
        }
예제 #2
0
        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;

                default:
                    break;
                }
            }
        }