Beispiel #1
0
        public static void Main()
        {
            var command = Console.ReadLine();
            var list    = command.Split().ToList();

            list.RemoveAt(0);
            ListyIterator <string> listy = new ListyIterator <string>(list);

            while (!command.Equals("END"))
            {
                try
                {
                    switch (command)
                    {
                    case "Print":
                        listy.Print();
                        break;

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

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

                    case "PrintAll":
                        var sb = new StringBuilder();
                        foreach (var item in listy)
                        {
                            sb.Append($"{item} ");
                        }
                        sb.Remove(sb.Length - 1, 1);
                        Console.WriteLine(sb);
                        break;
                    }
                }
                catch (ArgumentException arg)
                {
                    Console.WriteLine(arg.Message);
                }
                command = Console.ReadLine();
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            ListyIterator <string> collection = null;

            string command = Console.ReadLine();

            while (command != "END")
            {
                try
                {
                    var input    = command.Split(' ', StringSplitOptions.RemoveEmptyEntries);
                    var inputCmd = input[0];

                    if (inputCmd == "Create")
                    {
                        List <string> elements = input.Skip(1).ToList();
                        collection = new ListyIterator <string>(elements);
                    }
                    else if (inputCmd == "Move")
                    {
                        Console.WriteLine(collection.Move());
                    }
                    else if (inputCmd == "HasNext")
                    {
                        Console.WriteLine(collection.HasNext());
                    }
                    else if (inputCmd == "Print")
                    {
                        collection.Print();
                    }
                    else if (inputCmd == "PrintAll")
                    {
                        collection.PrintAll();
                    }
                }
                catch (InvalidOperationException exception)
                {
                    Console.WriteLine(exception.Message);
                }


                command = Console.ReadLine();
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            string input;
            ListyIterator <string> listyIterator = null;

            while ((input = Console.ReadLine()) != "END")
            {
                var cmdArgs = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                var command = cmdArgs[0];

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

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

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

                    break;

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

                case "PrintAll":
                    Console.WriteLine(listyIterator.PrintAll());
                    break;
                }
            }
        }
Beispiel #4
0
        public static void Main()
        {
            string[] createCommand            = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries);
            ListyIterator <string> collection = null;

            if (createCommand.Length != 1)
            {
                List <string> parameters = createCommand.Skip(1).ToList();
                collection = new ListyIterator <string>(parameters);
            }

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

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

                switch (input)
                {
                case "Print":
                    Console.WriteLine(collection.Print());;
                    break;

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

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

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

                default:
                    break;
                }
            }
        }
Beispiel #5
0
        public static void Main()
        {
            var inputCommand  = Console.ReadLine();
            var listyIterator = new ListyIterator <string>(inputCommand.Split(' ').Skip(1));

            while ((inputCommand = Console.ReadLine()).ToLower() != "end")
            {
                var tokens = inputCommand.Split(' ');

                switch (tokens[0])
                {
                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":
                    Console.WriteLine(string.Join(" ", listyIterator));
                    //foreach (var element in listyIterator)
                    //{
                    //    Console.Write($"{element} ");
                    //}
                    //Console.WriteLine();
                    break;
                }
            }
        }
Beispiel #6
0
        public static void Main()
        {
            var createCommand = Console.ReadLine().Split().ToList();

            createCommand.RemoveAt(0);
            var iterator = new ListyIterator <string>(createCommand);

            var command = Console.ReadLine();

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

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

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

                    case "PrintAll":
                        iterator.PrintAll();
                        break;
                    }
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine(ex.Message);
                }

                command = Console.ReadLine();
            }
        }
Beispiel #7
0
        public static void Main()
        {
            string[] input = Console.ReadLine().Split(' ').Skip(1).ToArray();

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

            string command = Console.ReadLine();

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

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

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

                case "PrintAll":
                    var result = new StringBuilder();

                    foreach (var element in collection)
                    {
                        result.Append(element + " ");
                    }

                    Console.WriteLine(result.ToString().Trim());

                    break;
                }

                command = Console.ReadLine();
            }
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            List <string> rawElements = Console.ReadLine().Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();

            rawElements.RemoveAt(0);

            if (rawElements.Count == 0)
            {
                rawElements = null;
            }

            ListyIterator <string> listyIterator = new ListyIterator <string>(rawElements);
            string input = Console.ReadLine();

            while (input != "END")
            {
                string[] command = input.Split(" ", StringSplitOptions.RemoveEmptyEntries);

                switch (command[0])
                {
                case "Move":
                    Console.WriteLine(listyIterator.Move());
                    break;

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

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

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

                input = Console.ReadLine();
            }
        }
Beispiel #9
0
        public static void Main()
        {
            List <string> createCommand = Console.ReadLine()
                                          .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                                          .Skip(1)
                                          .ToList();

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

            string command = Console.ReadLine();

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

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

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

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

                command = Console.ReadLine();
            }
        }
        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 "HasNext":
                        Console.WriteLine(data.HasNext());
                        break;

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

                    case "PrintAll":
                        Console.WriteLine(string.Join(" ", data));
                        break;
                    }
                }
            }
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            string command = Console.ReadLine();
            ListyIterator <string> listyIterator = null;

            while (command != "END")
            {
                try
                {
                    if (command.Contains("Create"))
                    {
                        List <string> commandArray = command.Split(' ', StringSplitOptions.RemoveEmptyEntries).Skip(1).ToList();
                        listyIterator = new ListyIterator <string>(commandArray);
                    }
                    else if (command == "Move")
                    {
                        Console.WriteLine(listyIterator.Move());
                    }
                    else if (command == "HasNext")
                    {
                        Console.WriteLine(listyIterator.HasNext());
                    }
                    else if (command == "Print")
                    {
                        listyIterator.Print();
                    }
                    else if (command == "PrintAll")
                    {
                        listyIterator.PrintAll();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                command = Console.ReadLine();
            }
        }
        static void Main(string[] args)
        {
            List <string>          items = Console.ReadLine().Split().Skip(1).ToList();
            ListyIterator <string> list  = new ListyIterator <string>(items);

            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 ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    break;

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

                command = Console.ReadLine();
            }
        }
        static void Main( )
        {
            ListyIterator <string> listyIterator = new ListyIterator <string>();

            string input;

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

                switch (cmd)
                {
                case "Create":
                    listyIterator.Create(args.Skip(1).ToArray());
                    break;

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

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

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

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

                default:
                    break;
                }
            }
        }
Beispiel #14
0
        static void Main(string[] args)
        {
            var input      = Console.ReadLine();
            var listItems  = input.Split().Skip(1).ToArray();
            var collection = new ListyIterator <string>(listItems);

            while ((input = Console.ReadLine()) != "END")
            {
                try
                {
                    switch (input)
                    {
                    case "HasNext":
                        Console.WriteLine(collection.HasNext());
                        break;

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

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

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

                    default:
                        break;
                    }
                }
                catch (InvalidOperationException ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            ListyIterator <string> listyIterator = null;

            while (input != "END")
            {
                string[] splitedInput = input
                                        .Split(" ", StringSplitOptions.RemoveEmptyEntries);
                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(listyIterator.PrintAll());
                }

                input = Console.ReadLine();
            }
        }
Beispiel #16
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 "PrintAll":
                    iterator.PrintAll(); break;

                case "HasNext":
                    bool next = iterator.HasNext();
                    iterator.Print(next);
                    break;

                case "Print":
                    try
                    {
                        iterator.Print();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    break;
                }
            }
        }
        static void Main()
        {
            var input = Console.ReadLine();
            ListyIterator <string> iterator = null;

            while (input != "END")
            {
                var tokens = input.Split(' ').ToList();
                switch (tokens[0])
                {
                case "Create":
                    iterator = new ListyIterator <string>(new List <string>(tokens.Skip(1)));
                    break;

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

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

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

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

                default: break;
                }

                input = Console.ReadLine();
            }
        }