Пример #1
0
        public static void Main()
        {
            var maker = new PizzaMaker(new ConsoleRenderer());

            var command = maker.Render.InputFromEnum <Command>(" What to do? ", ConsoleColor.DarkBlue);

            while ((Command)command != Command.Exit)
            {
                switch ((Command)command)
                {
                case Command.Create:
                    var pizzaName = maker.Render.Input("Pizza name");
                    var forWhere  = maker.Render.InputFromEnum <ForType>("Choose for: ");
                    var size      = maker.Render.InputFromEnum <SizeType>("Choose size: ");
                    var pizza     = maker.Create(pizzaName, (ForType)forWhere, (SizeType)size);

                    maker.Render.RenderPizza(pizza);

                    break;

                case Command.Sell:
                    var name = maker.Render.Input("Pizza to sell: ");
                    if (maker.Pizzas.All(p => p.Name != name))
                    {
                        break;
                    }

                    maker.Sell(maker.Pizzas.FirstOrDefault(p => p.Name == name));
                    break;

                default:
                    Environment.Exit(0);
                    break;
                }

                command = maker.Render.InputFromEnum <Command>(" What to do next? ", ConsoleColor.Black);
            }

            Console.ReadKey();
        }