예제 #1
0
        static void Main(string[] args)
        {
            var director      = new Director();
            var vicePresident = new VicePresident();
            var president     = new President();

            director.Successor      = vicePresident;
            vicePresident.Successor = president;

            var purchase = new Purchase(1, 2000);

            director.ProcessRequest(purchase);

            purchase = new Purchase(2, 20000);
            director.ProcessRequest(purchase);

            purchase = new Purchase(3, 100000);
            director.ProcessRequest(purchase);

            Console.ReadLine();
        }
예제 #2
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        public static void Run()
        {
            // Setup Chain of Responsibility
            Approver director      = new Director();
            Approver vicePresident = new VicePresident();
            Approver president     = new President();

            director.SetSuccessor(vicePresident);
            vicePresident.SetSuccessor(president);

            // Generate and process purchase requests
            Purchase p = new Purchase(2034, 350.00, "Assets");

            director.ProcessRequest(p);

            p = new Purchase(2035, 32590.10, "Project X");
            director.ProcessRequest(p);

            p = new Purchase(2036, 122100.00, "Project Y");
            director.ProcessRequest(p);

            // Wait for user
            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            // Setup Chain of Responsibility
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

            larry.SetSuccessor(sam);
            sam.SetSuccessor(tammy);

            // Generate and process purchase requests
            Purchase p = new Purchase(2034, 350.00, "Assets");

            larry.ProcessRequest(p);

            p = new Purchase(2035, 32590.10, "Project X");
            larry.ProcessRequest(p);

            p = new Purchase(2036, 122100.00, "Project Y");
            larry.ProcessRequest(p);

            Console.WriteLine("Press any key to exit...");
            Console.Read();
        }