示例#1
0
        static void Main(string[] args)
        {
            Baker baker = new Baker();

            BreadBuilder builder = new RyeBreadBuilder();

            Bread ryeBread = baker.Bake(builder);

            Console.WriteLine(ryeBread.ToString());

            builder = new WheatBreadBuilder();
            Bread wheatBread = baker.Bake(builder);

            Console.WriteLine(wheatBread.ToString());

            Console.Read();
        }
示例#2
0
        public void Run()
        {
            // содаем объект пекаря
            Baker baker = new Baker();
            // создаем билдер для ржаного хлеба
            BreadBuilder builder = new RyeBreadBuilder();
            // выпекаем
            Bread ryeBread = baker.Bake(builder);

            Console.WriteLine(ryeBread.ToString());
            // оздаем билдер для пшеничного хлеба
            builder = new WheatBreadBuilder();
            Bread wheatBread = baker.Bake(builder);

            Console.WriteLine(wheatBread.ToString());

            Console.Read();
        }
示例#3
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Title           = "Builder";

            // Объект пекаря
            Baker baker = new Baker();
            // Строитель для ржаного хлеба
            BreadBuilder breadBuilder = new RyeBreadBuilder();
            // Выпекаем
            Bread ryeBread = baker.Bake(breadBuilder);

            Console.WriteLine(ryeBread.ToString());

            // Строим пшеничный хлеб
            breadBuilder = new WheatBreadBuilder();
            Bread wheatBread = baker.Bake(breadBuilder);

            Console.WriteLine(wheatBread.ToString());

            Console.ReadKey();
        }
示例#4
0
        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();
        }
示例#5
0
 public void CreateBread()
 {
     Bread = new Bread();
 }