예제 #1
0
        static void Main(string[] args)
        {
            Abstraction ab = new RedefinedAbstraction();

            ab.Implementor = new ConcreteImplementorA();
            ab.Operation();

            ab.Implementor = new ConcreteImplementorB();
            ab.Operation();
        }
예제 #2
0
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">The command-line arguments.</param>
        public static void Main(string[] args)
        {
            // create a redefined abstraction for concrete implementor A
            Abstraction ab = new RedefinedAbstraction(new ConcreteImplementorA());

            // perform the high-level operation
            ab.Operation();

            // create a redefined abstraction for concrete implementor B
            ab = new RedefinedAbstraction(new ConcreteImplementorB());

            // perform the high-level operation
            ab.Operation();
        }
예제 #3
0
        static void Main(string[] args)
        {
            RedefinedAbstraction interestCalculation = new RedefinedAbstraction();

            interestCalculation.principal = 5000;
            interestCalculation.n         = 3;
            interestCalculation.r         = 10;

            interestCalculation.implementor = new SimpleInterestCalculation();
            interestCalculation.calculate();

            interestCalculation.implementor = new CompoundInterestCalculation();
            interestCalculation.calculate();
            Console.Read();
        }