Пример #1
0
        public 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;

                case "PrintAll":
                    Console.WriteLine(listylterator.PrintAll());
                    break;
                }

                input = Console.ReadLine();
            }
        }
Пример #2
0
        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();

                try
                {
                    switch (command)
                    {
                    case "Create":
                        listyIterator.Create(args);
                        break;

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

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

                    case "PrintAll":
                        Console.WriteLine(listyIterator.GetAllElements());
                        break;

                    case "HasNext":
                        Console.WriteLine(listyIterator.HasNext().ToString());
                        break;
                    }
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            ListyIterator <string> listIterator = null;

            while (input != "END")
            {
                string[] splitedInput = input.Split();

                string command = splitedInput[0];

                if (command == "Create")
                {
                    listIterator = new ListyIterator <string>(splitedInput.Skip(1).ToList());
                }
                else if (command == "Move")
                {
                    Console.WriteLine(listIterator.Move());
                }
                else if (command == "Print")
                {
                    Console.WriteLine(listIterator.Print());
                }
                else if (command == "HasNext")
                {
                    Console.WriteLine(listIterator.HasNext());
                }
                else if (command == "PrintAll")
                {
                    foreach (var element in listIterator)
                    {
                        Console.Write(element + " ");
                    }
                    Console.WriteLine();
                }

                input = Console.ReadLine();
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            while (true)
            {
                string input = Console.ReadLine();
                if (input == "END")
                {
                    break;
                }

                string[] splitedInput = input.Split();

                string command = splitedInput[0];

                if (command == "Create")
                {
                    listyIterator = new ListyIterator <string>(splitedInput.Skip(1).ToList());
                }
                else if (command == "Move")
                {
                    Console.WriteLine(listyIterator.Move());
                }
                else if (command == "Print")
                {
                    Console.WriteLine(listyIterator.Print());
                }
                else if (command == "HasNext")
                {
                    Console.WriteLine(listyIterator.HasNext());
                }
                else if (command == "PrintAll")
                {
                    Console.WriteLine(string.Join(" ", listyIterator));
                }
            }
        }
Пример #5
0
        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);
                    }
                }
                else if (command == "PrintAll")
                {
                    listyIterator.PrintAll();
                }
            }
        }
Пример #6
0
        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();
                }
                else if (command == "PrintAll")
                {
                    Console.WriteLine(string.Join(" ", listyIterator.PrintAll()));
                }
            }
        }
        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;

                    case "PrintAll":
                        Console.WriteLine(string.Join(' ', listyIterator));
                        break;
                    }
                }
                catch (InvalidOperationException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }