Пример #1
0
        static void Main()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            Supermarket queue = new Supermarket();

            StringBuilder answer = new StringBuilder();

            string command = Console.ReadLine();
            while (command != "End")
            {
                string commandResult = queue.ProcessCommand(command);
                answer.AppendLine(commandResult);
                command = Console.ReadLine();
            }
            answer.Length--;
            Console.WriteLine(answer);
        }
        public static void Main()
        {
            var supermarket = new Supermarket();

            var result = new StringBuilder();

            while (true)
            {
                string[] line = Console.ReadLine().Split(' ');

                string commandName = line[0];
                if (commandName == "End")
                {
                    break;
                }

                if (commandName == "Append")
                {
                    result.AppendLine(supermarket.Append(line[1]));
                }
                else if (commandName == "Insert")
                {
                    result.AppendLine(supermarket.Insert(int.Parse(line[1]), line[2]));
                }
                else if (commandName == "Find")
                {
                    result.AppendLine(supermarket.Find(line[1]).ToString());
                }
                else if (commandName == "Serve")
                {
                    result.AppendLine(supermarket.Serve(int.Parse(line[1])));
                }
            }

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