예제 #1
0
        static void Main(string[] args)
        {
            string[] createCommandItems = Console.ReadLine()
                                          .Split()
                                          .Skip(1)
                                          .ToArray();

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

            string command = Console.ReadLine();

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

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

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

                command = Console.ReadLine();
            }
        }
예제 #2
0
        public static void Main()
        {
            var createCmd = Console.ReadLine().Split().ToList();
            var elements  = createCmd.Skip(1).ToList();
            ListyIterator <string> listIterator = new ListyIterator <string>(elements);

            var cmd = Console.ReadLine();

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

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

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

                cmd = Console.ReadLine();
            }
        }
예제 #3
0
        static void Main()
        {
            var input = Console.ReadLine();
            ListyIterator <string> iterator = null;

            while (input != "END")
            {
                var command = input.Split(' ').ToArray();
                switch (command[0])
                {
                case "Create":
                    var collection = new List <string>();
                    for (int i = 1; i < command.Length; i++)
                    {
                        collection.Add(command[i]);
                    }
                    iterator = new ListyIterator <string>(collection);
                    break;

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

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

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

                input = Console.ReadLine();
            }
        }
예제 #4
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;
                    }
                }
                catch (ArgumentException arg)
                {
                    Console.WriteLine(arg.Message);
                }
                command = Console.ReadLine();
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = new ListyIterator <string>(new List <string>());

            string input = string.Empty;

            while ((input = Console.ReadLine()) != "END")
            {
                List <string> commandArgs = input.Split().ToList();
                string        command     = commandArgs[0];

                switch (command)
                {
                case "Create":
                    listyIterator.Create(commandArgs.Skip(1).ToList());
                    break;

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

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

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

                case "PrintAll":
                    Console.WriteLine(string.Join(" ", listyIterator));
                    break;
                }
            }
        }
        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;
                    }
                }
            }
        }
예제 #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;
                }

                command = Console.ReadLine();
            }
        }
예제 #8
0
        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;
                }

                command = Console.ReadLine();
            }
        }
예제 #9
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")
            {
                if (command.Contains("Move"))
                {
                    bool result = listyIterator.Move();
                    Console.WriteLine(result);
                }
                else if (command.Contains("Print"))
                {
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (InvalidOperationException exeption)
                    {
                        Console.WriteLine(exeption.Message);
                    }
                }
                else if (command.Contains("HasNext"))
                {
                    bool result = listyIterator.HasNext();
                    Console.WriteLine(result);
                }
                command = Console.ReadLine();
            }
        }
예제 #10
0
        public static void Main()
        {
            string inputLine = string.Empty;

            var input = Console.ReadLine().Split(new [] { " " }, StringSplitOptions.RemoveEmptyEntries).Skip(1);

            var result = new ListyIterator <string>();

            foreach (var s in input)
            {
                result.Add(s);
            }

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

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

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

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

                case "PrintAll":
                    try
                    {
                        foreach (var res in result)
                        {
                            Console.Write(res + " ");
                        }
                        Console.WriteLine();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    break;
                }
            }
        }
예제 #11
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);

            command = Console.ReadLine();

            while (true)
            {
                if (command == "END")
                {
                    break;
                }
                else
                {
                    if (command == "Print")
                    {
                        try
                        {
                            listyIterator.Print();
                        }
                        catch (Exception)
                        {
                            Console.WriteLine("Invalid operation!");
                        }
                    }

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

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

                    command = Console.ReadLine();
                }
            }
        }
예제 #12
0
        public static void Main()
        {
            var collection = new ListyIterator <string>();

            while (true)
            {
                var commands     = ParseInput();
                var firstCommand = commands[0];
                commands = commands.Skip(1).ToArray();
                if (firstCommand == "END")
                {
                    break;
                }

                try
                {
                    switch (firstCommand)
                    {
                    case "Create":
                        collection = new ListyIterator <string>(commands);
                        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;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
예제 #13
0
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine()
                             .Split(' ', StringSplitOptions.RemoveEmptyEntries);
            ListyIterator <string> listyIterator = new ListyIterator <string>(input.Skip(1).ToArray());
            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":
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (InvalidOperationException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    break;

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

                default:
                    break;
                }

                command = Console.ReadLine();
            }
        }
예제 #14
0
        public static void Main()
        {
            string inputLine;

            ListyIterator <string> iterator = null;

            while ((inputLine = Console.ReadLine()) != "END")
            {
                string[] tokens = inputLine.Split(new[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries);

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

                    iterator = new ListyIterator <string>(tokens.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;
                }
            }
        }
예제 #15
0
        private static string CommandsExecution(ListyIterator <string> collection)
        {
            var sb      = new StringBuilder();
            var cmdArgs = Console.ReadLine().Split();

            while (cmdArgs[0] != "END")
            {
                try
                {
                    switch (cmdArgs[0])
                    {
                    case "Move":
                        sb.AppendLine(collection.Move().ToString());
                        break;

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

                    case "HasNext":
                        sb.AppendLine(collection.HasNext().ToString());
                        break;

                    case "PrintAll":
                        foreach (var item in collection)
                        {
                            sb.Append($"{item} ");
                        }

                        sb.Remove(sb.Length - 1, 1);
                        sb.AppendLine();
                        break;

                    default:
                        break;
                    }
                }
                catch (ArgumentException ae)
                {
                    sb.AppendLine(ae.Message);
                }

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

            return(sb.ToString().Trim());
        }
예제 #16
0
        static void Main(string[] args)
        {
            List <string> inputInfo = Console
                                      .ReadLine()
                                      .Split(" ")
                                      .Skip(1)
                                      .ToList();

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

            string command = string.Empty;

            while ((command = Console.ReadLine()) != "END")
            {
                if (command == "Move")
                {
                    bool boolean = listyIterator.Move();
                    Console.WriteLine(boolean);
                }
                else if (command == "HasNext")
                {
                    bool boolean = listyIterator.HasNext();
                    Console.WriteLine(boolean);
                }
                else if (command == "Print")
                {
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (command == "PrintAll")
                {
                    foreach (var person in listyIterator)
                    {
                        Console.Write(person + " ");
                    }
                    Console.WriteLine();
                }
            }
        }
예제 #17
0
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            string cmd = string.Empty;

            while ((cmd = Console.ReadLine()) != "END")
            {
                try
                {
                    string[] arr = cmd
                                   .Split(" ", StringSplitOptions.RemoveEmptyEntries);

                    string command = arr[0];
                    switch (command)
                    {
                    case "Create":
                        List <string> elements = arr
                                                 .Skip(1)
                                                 .ToList();
                        listyIterator = new ListyIterator <string>(elements);
                        break;

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

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

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

                    case "PrintAll":
                        listyIterator.PrintAll();
                        break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
예제 #18
0
        static void Main()
        {
            string command = Console.ReadLine();

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

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

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

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

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

                command = Console.ReadLine();
            }
        }
예제 #19
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            ListyIterator <string> collection = new ListyIterator <string>();

            while (input != "END")
            {
                string[] tokens  = input.Split();
                string   command = tokens[0].ToLower();
                switch (command)
                {
                case "create":
                    List <string> nameCollection = new List <string>();
                    for (int i = 1; i < tokens.Length; i++)
                    {
                        nameCollection.Add(tokens[i]);
                    }
                    collection.Create(nameCollection);
                    break;

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

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

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

                default:
                    break;
                }

                input = Console.ReadLine();
            }
        }
예제 #20
0
        public static void Main()
        {
            ListyIterator listy = null;

            string inputInfo;

            while ((inputInfo = Console.ReadLine()) != "END")
            {
                var split = inputInfo.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                try
                {
                    switch (split[0])
                    {
                    case "Create":

                        listy = new ListyIterator(split.Skip(1).ToArray());
                        break;

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

                        break;

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

                        break;

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

                    case "PrintAll":
                        listy.PrintAll();
                        break;
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("Invalid Operation!");
                }
            }
        }
예제 #21
0
        public static void Main()
        {
            var inputCreate     = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var inputCreateData = inputCreate.Skip(1).ToArray();

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

            string input;

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

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

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

                    case "PrintAll":
                        foreach (var element in listyIterator)
                        {
                            Console.Write(element + " ");
                        }
                        Console.WriteLine();
                        break;
                    }
                }
                catch (ArgumentException ae)
                {
                    Console.WriteLine(ae.Message);
                }
            }
        }
예제 #22
0
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            ListyIterator <string> listyIterator = new ListyIterator <string>(
                input.Split(" ", StringSplitOptions.RemoveEmptyEntries).Skip(1).ToList());

            input = Console.ReadLine();

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

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

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

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

                    default:
                        break;
                    }
                }
                catch (InvalidOperationException ioe)
                {
                    Console.WriteLine(ioe.Message);
                }

                input = Console.ReadLine();
            }
        }
예제 #23
0
        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();
                }
            }
        }
예제 #24
0
        static void Main(string[] args)
        {
            string[] create = Console.ReadLine()
                              .Split(" ", StringSplitOptions.RemoveEmptyEntries)
                              .Skip(1)
                              .ToArray();

            ListyIterator <string> iterator = new ListyIterator <string>(create);

            string cmd = Console.ReadLine();

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

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

                case "Print":
                    try
                    {
                        iterator.Print();
                    }
                    catch (InvalidOperationException)
                    {
                        Console.WriteLine("Invalid Operation!");
                    }
                    break;

                default:
                    break;
                }
                cmd = Console.ReadLine();
            }
        }
예제 #25
0
        public static void Main()
        {
            var create   = Console.ReadLine().Split();
            var elements = create.Skip(1).Take(create.Length - 1).ToList();

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

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

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

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

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

                case "Print":
                    try
                    {
                        listyIterator.Print();
                    }
                    catch (InvalidOperationException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    break;
                }
            }
        }
예제 #26
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;
                }
            }
        }
예제 #27
0
파일: Program.cs 프로젝트: MartiHr/Softuni
        static void Main(string[] args)
        {
            ListyIterator <string> listyIterator = null;

            string command = string.Empty;

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

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

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

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

                case "HasNext":
                    Console.WriteLine(listyIterator.HasNext());
                    break;
                }
            }
        }
예제 #28
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")
            {
                switch (command)
                {
                case "Move":
                    Console.WriteLine(iterator.Move());
                    break;

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

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

                command = Console.ReadLine();
            }
        }
예제 #29
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;
                }

                input = Console.ReadLine();
            }
        }