Пример #1
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            string command = Console.ReadLine();

            while (command != "END")
            {
                try
                {
                    if (command.Contains("Create"))
                    {
                        List <string> items = command.Split().Skip(1).ToList();
                        listyIterator = new ListyIterator <string>(items);
                    }
                    else if (command == "Print")
                    {
                        listyIterator.Print();
                    }
                    else if (command == "HasNext")
                    {
                        Console.WriteLine(listyIterator.HasNext());
                    }
                    else if (command == "Move")
                    {
                        Console.WriteLine(listyIterator.Move());
                    }
                    else if (command == "PrintAll")
                    {
                        foreach (var item in listyIterator)
                        {
                            Console.Write(item + " ");
                        }
                        Console.WriteLine();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                command = Console.ReadLine();
            }
        }
Пример #2
0
        public static void Main()
        {
            string[]               input    = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);;
            List <string>          elements = input.Skip(1).ToList();
            ListyIterator <string> items    = new ListyIterator <string>(elements);

            string commandLine;

            while ((commandLine = Console.ReadLine()) != "END")
            {
                string[] commands = commandLine.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                try
                {
                    if (commands[0] == "HasNext")
                    {
                        Console.WriteLine(items.HasNext());
                    }

                    else if (commands[0] == "Move")
                    {
                        Console.WriteLine(items.Move());
                    }

                    else if (commands[0] == "Print")
                    {
                        items.Print();
                    }

                    else if (commands[0] == "PrintAll")
                    {
                        foreach (var item in items)
                        {
                            Console.Write(item + " ");
                        }
                        Console.WriteLine();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Пример #3
0
        public static void Main()
        {
            ListyIterator <string> listyIterator = null;

            string input = Console.ReadLine();

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

                string   command   = inputArgs[0];
                string[] arguments = inputArgs.Skip(1).ToArray();

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

                default:
                    throw new ArgumentException();
                }
                input = Console.ReadLine();
            }
        }
Пример #4
0
        static void Main(string[] args)
        {
            string command = Console.ReadLine();

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

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

            while (command != "END")
            {
                try
                {
                    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")
                    {
                        foreach (var item in listyIterator)
                        {
                            Console.Write(item + " ");
                        }
                        Console.WriteLine();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }


                command = Console.ReadLine();
            }
        }
Пример #5
0
        public static void Main(string[] args)
        {
            string[] data = Console.ReadLine().Split().Skip(1).ToArray();

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

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

                try
                {
                    string[] inputArgs = input.Split();
                    string   command   = inputArgs[0];

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

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

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

                    case "PrintAll":
                        list.PrintAll();
                        break;
                    }
                }
                catch (InvalidOperationException io)
                {
                    Console.WriteLine(io.Message);
                }
            }
        }
Пример #6
0
        public static void Main(string[] args)
        {
            var list = Console.ReadLine()
                       .Split()
                       .ToList();

            list.Remove("Create");

            ListyIterator <string> collection = new ListyIterator <string>(list.ToArray());

            while (true)
            {
                var command = Console.ReadLine();

                switch (command)
                {
                case "Move":
                    Console.WriteLine(collection.MoveNext());
                    break;

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

                case "PrintAll":
                    foreach (var item in collection)
                    {
                        Console.Write(item + " ");
                    }
                    Console.WriteLine();
                    break;

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

                case "END":
                    return;

                default:
                    break;
                }
            }
        }
Пример #7
0
        public static void Main()
        {
            string[] input = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            ListyIterator <string> collection = new ListyIterator <string>();

            collection.Create(input.Skip(1).ToArray());

            while (input[0] != "END")
            {
                if (input[0] == "Move")
                {
                    Console.WriteLine(collection.Move());
                }
                else if (input[0] == "HasNext")
                {
                    Console.WriteLine(collection.HasNext());
                }
                else if (input[0] == "Print")
                {
                    try
                    {
                        collection.Print();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
                else if (input[0] == "PrintAll")
                {
                    try
                    {
                        collection.PrintAll();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }

                input = Console.ReadLine().Split();
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            List <string> command = Console.ReadLine().Split().Skip(1).ToList();
            var           myList  = new ListyIterator <string>(command);

            string nextOperation = Console.ReadLine();

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

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

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

                case "PrintAll":

                    foreach (var item in myList)
                    {
                        Console.Write(item + " ");
                    }
                    Console.WriteLine();
                    break;
                }

                nextOperation = Console.ReadLine();
            }
        }
Пример #9
0
        static void Main(string[] args)
        {
            List <string> elements = Console.ReadLine()
                                     .Split()
                                     .Skip(1)
                                     .ToList();
            ListyIterator <string> iterator = new ListyIterator <string>(elements);

            string[] commands = Console.ReadLine().Split();

            while (commands[0] != "END")
            {
                switch (commands[0])
                {
                case "Move":
                    Console.WriteLine(iterator.Move());
                    break;

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

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

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

                default:
                    break;
                }
                commands = Console.ReadLine().Split();
            }
        }
Пример #10
0
        static void Main(string[] args)
        {
            string[] command             = Console.ReadLine().Split();
            ListyIterator <string> listy = new ListyIterator <string>();

            while (command[0] != "END")
            {
                if (command[0] == "Create")
                {
                    string[] sub = command.Where(x => x != "Create").ToArray();
                    listy.Create(sub);
                }

                if (command[0] == "Print")
                {
                    listy.Print();
                }

                if (command[0] == "PrintAll")
                {
                    listy.PrintAll();
                }

                if (command[0] == "HasNext")
                {
                    Console.WriteLine(listy.HasNext());
                }

                if (command[0] == "Move")
                {
                    Console.WriteLine(listy.Move());
                }

                command = Console.ReadLine().Split();
            }

            Console.WriteLine("******************************");

            foreach (var item in listy)
            {
                Console.WriteLine(item);
            }
        }
        static void Main(string[] args)
        {
            ListyIterator <string> collection = new ListyIterator <string>();

            while (true)
            {
                string command = Console.ReadLine();
                if (command == "END")
                {
                    break;
                }
                else
                {
                    string[] parts = command.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                    DoCommands(parts, collection);
                }
            }
            Console.ReadLine();
        }
Пример #12
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            while (true)
            {
                try
                {
                    string input = Console.ReadLine();

                    if (input == "END")
                    {
                        break;
                    }

                    if (input.Contains("Create"))
                    {
                        List <string> items = input.Split().Skip(1).ToList();
                        listyIterator = new ListyIterator <string>(items);
                    }
                    else if (input == "Print")
                    {
                        listyIterator.Print();
                    }
                    else if (input == "HasNext")
                    {
                        Console.WriteLine(listyIterator.HasNext());
                    }
                    else if (input == "Move")
                    {
                        Console.WriteLine(listyIterator.Move());
                    }
                    else if (input == "PrintAll")
                    {
                        Console.WriteLine(string.Join(" ", listyIterator));
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Пример #13
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            while (true)
            {
                string line = Console.ReadLine();

                if (line == "END")
                {
                    break;
                }

                string[] tokens  = line.Split();
                string   command = tokens[0];
                if (command == "Create")
                {
                    listyIterator = new ListyIterator <string>(tokens.Skip(1).ToList());
                }
                else if (command == "Move")
                {
                    Console.WriteLine(listyIterator.Move());
                }
                else if (command == "HasNext")
                {
                    Console.WriteLine(listyIterator.HasNext());
                }
                else if (command == "Print")
                {
                    Console.WriteLine(listyIterator.Print());
                }
                else if (command == "PrintAll")
                {
                    Console.WriteLine(string.Join(" ", listyIterator));

                    //foreach (var item in listyIterator)
                    //{
                    //    Console.Write(item + " ");
                    //}
                }
            }
        }
Пример #14
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            string command;

            while ((command = Console.ReadLine()) != "END")
            {
                var tokens = command
                             .Split(" ", StringSplitOptions.RemoveEmptyEntries);

                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":
                    Console.WriteLine(string.Join(" ", listyIterator));
                    break;
                }
            }
        }
Пример #15
0
        static void Main(string[] args)
        {
            var input = "";
            ListyIterator <string> list = null;

            while ((input = Console.ReadLine()) != "END")
            {
                var data    = input.Split();
                var command = data[0];

                try
                {
                    switch (command)
                    {
                    case "Create":
                        var items = data.Skip(1).ToArray();
                        list = new ListyIterator <string>(items);
                        break;

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

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

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

                    case "PrintAll":
                        Console.WriteLine(string.Join(" ", list));
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Пример #16
0
        public static void Main()
        {
            string command  = Console.ReadLine();
            var    elements = command
                              .Split()
                              .Skip(1)
                              .ToList();

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

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

                command = Console.ReadLine();
            }
        }
Пример #17
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(new[] { " " }, StringSplitOptions.RemoveEmptyEntries));
                }



                else
                {
                    switch (input)
                    {
                    case "Move":
                        Console.WriteLine(data.Move());
                        break;



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

                    case "HasNext":
                        Console.WriteLine(data.Next());
                        break;
                    }
                }
            }
        }
Пример #18
0
        static void Main(string[] args)
        {
            string[] createCommand = Console.ReadLine()
                                     .Split()
                                     .Skip(1)
                                     .ToArray();
            ListyIterator <string> list = new ListyIterator <string>(createCommand);

            string command = Console.ReadLine();

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

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

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

                case "PrintAll":
                    list.PrintAll();
                    break;
                }
                command = Console.ReadLine();
            }
        }
        static void Main(string[] args)
        {
            string        command = Console.ReadLine();
            List <string> input   = new List <string>();
            bool          isEnd   = true;

            while (isEnd)
            {
                command = command.Remove(0, 6);
                input   = command.Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
                ListyIterator <string> listy = new ListyIterator <string>(input);

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

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

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

                    case "PrintAll":
                        foreach (var item in listy)
                        {
                            Console.Write($"{item} ");
                        }
                        Console.WriteLine();
                        break;
                    }
                }
                isEnd = false;
            }
        }
        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;

                default:
                    throw new ArgumentException();
                }
            }
        }
        static void Main(string[] args)
        {
            string[] createData = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).Skip(1).ToArray();


            ListyIterator <string> dataList = new ListyIterator <string>(createData);

            string nextComand;

            while ((nextComand = Console.ReadLine()) != "END")
            {
                switch (nextComand.ToUpper())
                {
                case "MOVE":

                    Console.WriteLine(dataList.Move());
                    break;

                case "PRINT":

                    dataList.Print();
                    break;

                case "HASNEXT":

                    Console.WriteLine(dataList.HasNext());
                    break;

                case "PRINTALL":

                    dataList.PrintAll();
                    break;

                default:
                    break;
                }
            }

            //Console.WriteLine("Hello World!");
        }
Пример #22
0
        public static void Main(string[] args)
        {
            var command = "";

            var elements = Console.ReadLine()
                           .Split()
                           .Skip(1)
                           .ToList();

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


            while ((command = Console.ReadLine()) != "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")
                {
                    Console.WriteLine(string.Join(" ", listyIterator));
                }
            }
        }
Пример #23
0
        public 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 "Print":
                    try
                    {
                        list.Print();
                    }
                    catch (InvalidOperationException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }

                    break;
                }

                command = Console.ReadLine();
            }
        }
Пример #24
0
        static void Main(string[] args)
        {
            List <string>          elements = Console.ReadLine().Split().Skip(1).ToList();
            ListyIterator <string> list     = new ListyIterator <string>(elements);

            string input = "";

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

                switch (command)
                {
                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":
                    Console.WriteLine(string.Join(" ", list));
                    break;
                }
            }
        }
Пример #25
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;
                }
                }
            }
        }
Пример #26
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = new ListyIterator <string>();
            string input = Console.ReadLine();

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

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

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

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

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

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

                default:
                    break;
                }

                input = Console.ReadLine();
            }
        }
Пример #27
0
        private static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split().Skip(1).ToArray();
            ListyIterator <string> list = new ListyIterator <string>(input.ToList());

            string command = Console.ReadLine();

            while (command != "END")
            {
                if (command == "Print")
                {
                    try
                    {
                        list.Print();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (command == "Move")
                {
                    Console.WriteLine(list.Move());
                }
                else if (command == "HasNext")
                {
                    Console.WriteLine(list.HasNext());
                }
                else if (command == "PrintAll")
                {
                    foreach (var element in list)
                    {
                        Console.Write(element + " ");
                    }
                    Console.WriteLine();
                }
                command = Console.ReadLine();
            }
        }
Пример #28
0
        static void Main(string[] args)
        {
            List <string>          items = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).Skip(1).ToList();
            ListyIterator <string> List  = new ListyIterator <string>(items);

            string comand = Console.ReadLine();

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

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

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

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


                comand = Console.ReadLine();
            }
        }
Пример #29
0
        static void Main(string[] args)
        {
            string[] creationData = Console.ReadLine().Substring(6).Split(" ", StringSplitOptions.RemoveEmptyEntries);

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

            string command = Console.ReadLine();

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

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

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

                case "PrintAll":
                    list.PrintAll();
                    break;
                }

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

            string[] line = Console.ReadLine()
                            .Split();

            while (line[0] != "END")
            {
                try
                {
                    if (line[0] == "Create")
                    {
                        List <string> items = line.Skip(1).ToList();
                        listyIterator = new ListyIterator <string>(items);
                    }
                    else if (line[0] == "Print")
                    {
                        listyIterator.Print();
                    }
                    else if (line[0] == "Move")
                    {
                        Console.WriteLine(listyIterator.Move());
                    }
                    else if (line[0] == "HasNext")
                    {
                        Console.WriteLine(listyIterator.HasNext());
                    }
                }
                catch
                {
                    Console.WriteLine("Invalid Operation!");
                }

                line = Console.ReadLine()
                       .Split();
            }
        }