Пример #1
0
        public static void Main()
        {
            ListyIterator <string> listyIterator = new ListyIterator <string>();

            string command;

            while ((command = Console.ReadLine()) != "END")
            {
                try
                {
                    var data = command.Split();

                    switch (data[0])
                    {
                    case "Create": listyIterator.Create(data.Skip(1).ToArray()); break;

                    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);
                }
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var listyIterator = new ListyIterator <string>();

            var input = Console.ReadLine();
            var data  = input
                        .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                        .Skip(1)
                        .ToList();

            listyIterator.Create(data);

            while ((input = Console.ReadLine()) != "END")
            {
                switch (input)
                {
                case "Move":
                    Console.WriteLine(listyIterator.Move());
                    break;

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

                case "Print":
                    listyIterator.Print();
                    break;

                case "PrintAll":
                    listyIterator.PrintAll();
                    break;
                }
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = new ListyIterator <string>();

            string[] create = Console.ReadLine().Split();
            listyIterator.Create(create);

            string input = Console.ReadLine();

            while (input != "END")
            {
                if (input == "Move")
                {
                    Console.WriteLine(listyIterator.Move());
                }
                else if (input == "HasNext")
                {
                    Console.WriteLine(listyIterator.HasNext());
                }
                else if (input == "Print")
                {
                    listyIterator.Print();
                }
                else if (input == "PrintAll")
                {
                    foreach (var item in listyIterator)
                    {
                        Console.Write(item + " ");
                    }
                    Console.WriteLine();
                }
                input = Console.ReadLine();
            }
        }
Пример #4
0
        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 "PrintAll":
                        Console.WriteLine(string.Join(" ", data));
                        break;


                    case "HasNext":
                        Console.WriteLine(data.HasNext());
                        break;

                    case "Print":
                        data.Print();
                        break;
                    }
                }
            }
        }