Пример #1
0
        private void mainConstructor(BouquetWrapper wrapper)
        {
            this.Wrapper = wrapper;

            if (!Name.Contains("Wrapped"))
            {
                Name = Name.ToLower();
                Name = Name.Insert(0, "Wrapped");
            }
            switch (wrapper.Wrapper)
            {
            case Lab2.Wrapper.Organza:
                Price += 10;
                break;

            case Lab2.Wrapper.Paper:
                Price += 5;
                break;

            case Lab2.Wrapper.Tape:
                Price += 3;
                break;
            }
        }
Пример #2
0
        public static void Menu()
        {
            MainMenu();
            char mode = ' ';

            Bouquet    currentBuquet = null;
            FlowerShop shop          = FlowerShop.GetSource();

            do
            {
                mode = Program.EnterMode();
                switch (mode)
                {
                case 'o':
                    MainMenu();
                    break;

                case 'c':
                    shop.SetBuilder(new CascadeBouquetBuilder());
                    currentBuquet = shop.Menu();
                    MainMenu();
                    break;

                case 'r':
                    shop.SetBuilder(new RoundBouquetBuilder());
                    currentBuquet = shop.Menu();
                    MainMenu();
                    break;

                case 't':
                    shop.SetBuilder(new TriangularBouquetBuilder());
                    currentBuquet = shop.Menu();
                    MainMenu();
                    break;

                case 'i':
                    if (currentBuquet != null)
                    {
                        currentBuquet.GetInfo();
                    }
                    else
                    {
                        Console.WriteLine(" < Bouquet wasn't constructed > ");
                    }
                    break;

                case 'w':
                    if (currentBuquet != null)
                    {
                        BouquetWrapper wrapper = new BouquetWrapper();
                        wrapper.ChooseWrapper();
                        MainMenu();
                        currentBuquet = new WrappedBouquet(currentBuquet, wrapper);
                    }
                    else
                    {
                        Console.WriteLine(" < Bouquet wasn't constructed > ");
                    }
                    break;

                case 'p':
                    if (currentBuquet != null)
                    {
                        Postcard postcard = new Postcard();
                        postcard.SignPostcard();
                        currentBuquet = new SignedBouquet(currentBuquet, postcard);
                    }
                    else
                    {
                        Console.WriteLine(" < Bouquet wasn't constructed > ");
                    }
                    break;

                case 'q':
                    break;

                default:
                    Console.WriteLine(" < Wrong mode > ");
                    break;
                }
            } while (mode != 'q');
        }
Пример #3
0
 public BouquetDecorator(Bouquet bouquet) : base(bouquet)
 {
     Wrapper      = null;
     Postcard     = null;
     this.bouquet = bouquet;
 }
Пример #4
0
 public WrappedBouquet(Bouquet bouquet, BouquetWrapper wrapper) : base(bouquet)
 {
     mainConstructor(wrapper);
 }
Пример #5
0
 public WrappedBouquet(SignedBouquet bouquet, BouquetWrapper wrapper) : base(bouquet)
 {
     Postcard = bouquet.Postcard;
     mainConstructor(wrapper);
 }