Пример #1
0
        public static void Main()
        {
            var input = Console.ReadLine()
                        .Split(' ')
                        .Skip(1)
                        .ToList();

            var list = new ListyIterator <string>(input);

            string command;

            while ((command = Console.ReadLine()) != "END")
            {
                try
                {
                    switch (command)
                    {
                    case "Move": Console.WriteLine(list.Move()); break;

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

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

                    case "PrintAll": list.PrintAll(); break;
                    }
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }
        }
Пример #2
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);
                }
            }
        }
Пример #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
        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;
                }
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            ListyIterator <string> iterator = null;
            string command = null;

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

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

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

                case "Print":
                    Console.WriteLine(iterator.Print());
                    break;

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

                case "PrintAll":
                    Console.WriteLine(iterator.PrintAll());
                    break;
                }
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            string[] data     = Console.ReadLine()?.Split(" ", StringSplitOptions.RemoveEmptyEntries) ?? new string[] { };
            string[] elements = new string[data.Length - 1];
            Array.Copy(data, 1, elements, 0, elements.Length);
            ListyIterator <string> list = new ListyIterator <string>(elements);

            string input = Console.ReadLine();

            while (input != "END")
            {
                try
                {
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                switch (input)
                {
                case "Move":
                    var result = list.Move();
                    Console.WriteLine(result);
                    break;

                case "HasNext":
                    result = list.HasNext();
                    Console.WriteLine(result);
                    break;

                case "Print":
                    try
                    {
                        var element = list.Print();
                        Console.WriteLine(element);
                    }
                    catch (InvalidOperationException exception)
                    {
                        Console.WriteLine(exception.Message);
                    }
                    break;

                case "PrintAll":
                    var output = list.PrintAll();
                    Console.WriteLine(output);
                    break;
                }

                input = Console.ReadLine();
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            string[] tokens = input.Split();
            ListyIterator <string> listyIterator = new ListyIterator <string>(tokens.Skip(1).ToList());

            while ((input = Console.ReadLine()) != "END")
            {
                tokens = input.Split();
                switch (tokens[0])
                {
                case ("Move"):
                {
                    Console.WriteLine(listyIterator.Move());
                    break;
                }

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

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

                case ("PrintAll"):
                {
                    try
                    {
                        listyIterator.PrintAll();
                    }
                    catch (ArgumentException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    break;
                }
                }
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            List <string> input = Console.ReadLine()
                                  .Split()
                                  .Skip(1)
                                  .ToList();

            ListyIterator <string> list = new ListyIterator <string>(input);

            string command = Console.ReadLine();

            while (command != "END")
            {
                switch (command)
                {
                case "HasNext":
                    Console.WriteLine(list.HasNext());
                    break;

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

                case "PrintAll":
                    try
                    {
                        list.PrintAll();
                    }
                    catch (InvalidOperationException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    break;

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

                    break;
                }

                command = Console.ReadLine();
            }
        }
Пример #9
0
        public static void Main()
        {
            string input = Console.ReadLine();
            ListyIterator <string> iterator = null;

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

                switch (args[0])
                {
                case "Create":

                    iterator = new ListyIterator <string>(args.Skip(1));
                    break;

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

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

                case "Print":

                    try
                    {
                        Console.WriteLine(iterator.Print());
                    }
                    catch (ArgumentException ae)
                    {
                        Console.WriteLine(ae.Message);
                    }

                    break;

                case "PrintAll":

                    foreach (string item in iterator)
                    {
                        Console.Write($"{item} ");
                    }

                    Console.WriteLine();
                    break;
                }

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

            string input = Console.ReadLine();

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

                string command = inputArgs[0];

                switch (command)
                {
                case "Create":
                    listyIterator = new ListyIterator <string>(inputArgs.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;

                case "PrintAll":
                    foreach (var item in listyIterator)
                    {
                        Console.Write(item + " ");
                    }
                    Console.WriteLine();
                    break;
                }
                input = Console.ReadLine();
            }
        }
Пример #11
0
        static void Main()
        {
            string input = Console.ReadLine();

            string[] tokens = input.Split();

            ListyIterator <string> listyIterator = new ListyIterator <string>(tokens.Skip(1).ToList());

            while (input != "END")
            {
                tokens = input.Split();
                string command = tokens[0];

                switch (command)
                {
                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":
                    try
                    {
                        listyIterator.PrintAll();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    break;
                }
                input = Console.ReadLine();
            }
        }
Пример #12
0
        public static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split().Skip(1).ToArray();

            ListyIterator <string> list = new ListyIterator <string>(data);

            string input = Console.ReadLine();

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

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

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

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

                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;
                }
            }
        }
Пример #14
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;
                    }
                }
            }
        }
Пример #15
0
        public static void Main(string[] args)
        {
            var myList = new List <string>();

            string                 command       = Console.ReadLine();
            List <string>          elements      = command.Split().Skip(1).ToList();
            ListyIterator <string> listyIterator = new ListyIterator <string>(elements);

            while (command != "END")
            {
                if (command == "Print")
                {
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }

                else if (command == "Move")
                {
                    bool result = listyIterator.Move();
                    Console.WriteLine(result);
                }

                else if (command == "HasNext")
                {
                    bool result = listyIterator.HasNext();
                    Console.WriteLine(result);
                }

                else if (command == "PrintAll")
                {
                    foreach (var item in listyIterator)
                    {
                        Console.Write(item + " ");
                    }
                    Console.WriteLine();
                }
                command = Console.ReadLine();
            }
        }
Пример #16
0
        static void Main(string[] args)
        {
            string input        = Console.ReadLine();
            var    command      = input.Split().Skip(1).ToArray();
            var    listIterator = new ListyIterator <string>(command);

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

                case "Print":
                    try
                    {
                        listIterator.Print();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    break;

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

                case "PrintAll":
                    foreach (var item in listIterator)
                    {
                        Console.Write($"{item} ");
                    }

                    Console.WriteLine();
                    break;

                default:
                    break;
                }
            }
        }
        static void Main(string[] args)
        {
            var data = Console.ReadLine()
                       .Split()
                       .Skip(1)
                       .ToList();
            ListyIterator <string> list = new ListyIterator <string>(data);

            string input = string.Empty;

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

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

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

                case "PrintAll":
                    Console.WriteLine(string.Join(" ", list));
                    break;

                default:
                    break;
                }
            }
        }
Пример #18
0
        static void Main(string[] args)
        {
            var command = Console.ReadLine();

            var elements = command.Split().Skip(1).ToList();

            ListyIterator <string> listyIterator = new ListyIterator <string>(elements);

            while (command != "END")
            {
                if (command == "Print")
                {
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (command == "Move")
                {
                    Console.WriteLine(listyIterator.Move());
                }
                else if (command == "HasNext")
                {
                    Console.WriteLine(listyIterator.HasNext());
                }
                else if (command == "PrintAll")
                {
                    foreach (var item in listyIterator)
                    {
                        Console.Write($"{item} ");
                    }
                    Console.WriteLine();
                }


                command = Console.ReadLine();
            }
        }
Пример #19
0
        static void Main()
        {
            string input;

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

                    if (command == "Create")
                    {
                        string[] arr = arguments.Skip(1).ToArray();
                        store = new ListyIterator <string>(arr);
                    }
                    else if (command == "Print")
                    {
                        store.Print();
                    }
                    else if (command == "PrintAll")
                    {
                        store.PrintAll();
                    }
                    else if (command == "HasNext")
                    {
                        Console.WriteLine(store.HasNext());
                    }
                    else if (command == "Move")
                    {
                        Console.WriteLine(store.Move());
                    }
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }
        }
Пример #20
0
        public static void Main(string[] args)
        {
            string command = Console.ReadLine();

            List <string>          elements      = command.Split().Skip(1).ToList();
            ListyIterator <string> listyIterator = new ListyIterator <string>(elements);

            try
            {
                while (command != "END")
                {
                    if (command == "Print")
                    {
                        listyIterator.Print();
                    }
                    else if (command == "Move")
                    {
                        bool result = listyIterator.Move();
                        Console.WriteLine(result);
                    }
                    else if (command == "HasNext")
                    {
                        bool result = listyIterator.HasNext();
                        Console.WriteLine(result);
                    }
                    else if (command == "PrintAll")
                    {
                        Console.WriteLine(string.Join(" ", listyIterator));
                    }

                    command = Console.ReadLine();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        static void Main(string[] args)
        {
            var input = Console.ReadLine()
                        .Split(' ', StringSplitOptions.RemoveEmptyEntries)
                        .Skip(1)
                        .ToArray();

            ListyIterator <string> listyIterator = new ListyIterator <string>(input);

            string command = Console.ReadLine();

            while (command != "END")
            {
                if (command == "Move")
                {
                    Console.WriteLine(listyIterator.Move());
                }
                else if (command == "Print")
                {
                    listyIterator.Print();
                }
                else if (command == "HasNext")
                {
                    Console.WriteLine(listyIterator.HasNext());
                }
                else if (command == "PrintAll")
                {
                    foreach (var item in listyIterator)
                    {
                        Console.Write($"{item} ");
                    }
                    Console.WriteLine();
                }

                command = Console.ReadLine();
            }
        }
        static void DoCommands(string[] parts, ListyIterator <string> collection)
        {
            switch (parts[0])
            {
            case "Create":
                if (parts.Length == 1)
                {
                    collection.List = new List <string>();
                }
                else
                {
                    parts           = parts.Skip(1).Take(parts.Length - 1).ToArray();
                    collection.List = new List <string>(parts);
                }
                break;

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

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

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

            case "PrintAll":
                collection.PrintAll();
                break;

            default:
                break;
            }
        }