コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Bridge Pattern");

            Electronics item         = new Television();
            IState      presentState = new OnState();

            item.State   = presentState;
            presentState = new OffState();
            item.State   = presentState;
            item.MoveToCurrentState();

            presentState = new OnState();
            item.State   = presentState;
            item.MoveToCurrentState();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("***Bridge Pattern Demo.***");
            Console.WriteLine("Verifying the market price of a television.");
            ElectronicGoods eItem = new Television();

            eItem.ProductType = "Sony Television";
            //Verifying online  price
            IPrice price = new OnlinePrice();

            eItem.Price = price;
            eItem.Details();
            //Verifying showroom price
            price       = new ShowroomPrice();
            eItem.Price = price;
            eItem.Details();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: marcel1992/DesignPatterns
        static void Main(string[] args)
        {
            Console.WriteLine("Bridge Pattern");

            #region Television details

            Console.WriteLine("Verifying the market price of a television");
            ElectronicGoods electronicGood = new Television(new OnlinePrice());
            //verify online price details
            electronicGood.Details();
            //giving 10% discount
            electronicGood.Discount(10);

            //verify showroom price
            electronicGood = new Television(new ShowroomPrice());
            electronicGood.Details();
            //giving 10% discount
            electronicGood.Discount(10);

            #endregion

            #region DVD details

            Console.WriteLine("Verifying the market price of a DVD");
            electronicGood = new DVD(new OnlinePrice());
            //verify online price details
            electronicGood.Details();
            //giving 10% discount
            electronicGood.Discount(10);

            //verify showroom price
            electronicGood = new DVD(new ShowroomPrice());
            electronicGood.Details();
            Console.WriteLine("In showroom, you want to give double discounts at festive season!");
            Console.WriteLine("For DVD you can get double discounts using the DoubleDiscount() method");
            ((DVD)electronicGood).DoubleDiscount();

            #endregion

            Console.Read();
        }