Esempio n. 1
0
        private static void Main()
        {
            var receiver = new Receiver(false, true, false);

            var bank   = new BankPaymentHandler();
            var paypal = new PayPalPaymentHandler();
            var money  = new MoneyPaymentHandler();

            bank.Successor   = paypal;
            paypal.Successor = money;

            bank.Handle(receiver);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Receiver receiver = new Receiver(false, true, true);

            PaymentHandler bankPaymentHandler   = new BankPaymentHandler();
            PaymentHandler moneyPaymentHnadler  = new MoneyPaymentHandler();
            PaymentHandler paypalPaymentHandler = new PayPalPaymentHandler();

            bankPaymentHandler.Successor   = paypalPaymentHandler;
            paypalPaymentHandler.Successor = moneyPaymentHnadler;

            bankPaymentHandler.Handle(receiver);

            Console.Read();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Green;
            Console.Title           = "Chain Of Responsibility";

            // Выставляем флаги нужных нам вариантов переводов
            Receiver receiver = new Receiver(false, true, true);

            PaymentHandler bankPaymentHandler   = new BankPaymentHandler();
            PaymentHandler moneyPaymentHandler  = new MoneyPaymentHandler();
            PaymentHandler paypalPaymentHandler = new PayPalPaymentHandler();

            bankPaymentHandler.Successor   = paypalPaymentHandler;
            paypalPaymentHandler.Successor = moneyPaymentHandler;

            bankPaymentHandler.Handle(receiver);

            receiver = new Receiver(false, true, false);
            paypalPaymentHandler.Handle(receiver);

            Console.ReadKey();
        }