static void Main(string[] args) { var key = new ConsoleKeyInfo(); while (!(key.Key == ConsoleKey.D3 || key.Key == ConsoleKey.NumPad3)) { var cocina = new Cocina(); Pizza pizza = null; key = ShowMenu(); switch (key.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: pizza = cocina.CocinarPizza(new CuatroQuesosBuilder(TamañoEnum.Familiar)); break; case ConsoleKey.D2: case ConsoleKey.NumPad2: pizza = cocina.CocinarPizza(new HawaianaBuilder(TamañoEnum.Mediana)); break; } if (key.Key != ConsoleKey.D3 && key.Key != ConsoleKey.NumPad3 && key.Key != ConsoleKey.Escape) { Console.WriteLine(); Console.WriteLine(pizza.ToString()); Wait(); } } }
static void Main(string[] args) { Baker baker = new Baker(); BreadBuilder builder = new RyeBreadBuilder(); baker.Bake(builder); Bread ryeBread = builder.Bread; Console.WriteLine(ryeBread.ToString()); builder = new WheatBreadBuilder(); baker.Bake(builder); Bread wheatBread = builder.Bread; Console.WriteLine(wheatBread.ToString()); Console.WriteLine("--------------\n"); PizzaBuilder italyBuilder = new MeatPizzaBuilder(); baker.Bake(italyBuilder); Pizza meatPizza = italyBuilder.Pizza; Console.WriteLine(meatPizza.ToString()); italyBuilder = new SeafoodPizzaBuilder(); baker.Bake(italyBuilder); Pizza seafoodPizza = italyBuilder.Pizza; Console.WriteLine(seafoodPizza.ToString()); Console.ReadKey(); }