Exemplo n.º 1
0
 /// <summary>
 /// Entry point into console application.
 /// </summary>
 static void Main()
 {
     // 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);
     // Wait for user
     Console.ReadKey();
 }
Exemplo n.º 2
0
        internal static void Main()
        {
            Approver teamLead = new TeamLead();
            Approver vp = new VicePresident();
            Approver ceo = new President();

            teamLead.SetSuccessor(vp);
            vp.SetSuccessor(ceo);

            var purchase = new Purchase(2034, 350.00);
            teamLead.ProcessRequest(purchase);

            purchase = new Purchase(2035, 32590.10);
            teamLead.ProcessRequest(purchase);

            purchase = new Purchase(2036, 122100.00);
            teamLead.ProcessRequest(purchase);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        static void Main()
        {
            // 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);
            // Wait for user
            Console.ReadKey();
        }
Exemplo n.º 4
0
        public static void Main(string[] args)
        {
            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

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

            var 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.ReadKey();
        }
Exemplo n.º 5
0
        public static void Main()
        {
            // 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
            var 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);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Chain of responsibility");

            Approver larry = new Director();
            Approver sam   = new VicePresident();
            Approver tammy = new President();

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

            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);
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            //Nesneler Arası Hiyerarşik yapı ..
            // Örn : Şirkette harcamaların 100 Tl altındaysa Müdür yetki verebiliyor
            // Fiyat arttıkça bi üst kişi yetkilendirir

            Manager       manager       = new Manager();
            VicePresident vicePresident = new VicePresident();
            President     president     = new President();

            manager.SetSuccessor(vicePresident);
            vicePresident.SetSuccessor(president);

            Expense expense = new Expense {
                Detail = "Training", Amount = 918
            };

            manager.HandleExpense(expense);

            Console.ReadLine();
        }
Exemplo n.º 8
0
        private static void Main()
        {
            Approver employee            = new Employee();
            Approver theHeadOfDepartment = new HeadOfDepartment();
            Approver thePresident        = new President();

            // employee -> theHeadOfDepartment -> thePresident
            employee.SetSuccessor(theHeadOfDepartment);
            theHeadOfDepartment.SetSuccessor(thePresident);

            // generate and process purchase requests
            var amount         = 350.00;
            var purchaseNumber = 1;
            var firstPurchase  = new Purchase(purchaseNumber, amount, $"{purchaseNumber} purchase with amount: {amount}");

            employee.ProcessRequest(firstPurchase);
            ReadLine();

            amount         = 19000.10;
            purchaseNumber = 2;
            var secondPurchase = new Purchase(purchaseNumber, amount, $"{purchaseNumber} purchase with amount: {amount}");

            employee.ProcessRequest(secondPurchase);
            ReadLine();

            amount         = 32590.10;
            purchaseNumber = 3;
            var thirdPurchase = new Purchase(purchaseNumber, amount, $"{purchaseNumber} purchase with amount: {amount}");

            employee.ProcessRequest(thirdPurchase);
            ReadLine();

            amount         = 122100.00;
            purchaseNumber = 4;
            var fourthPurchase = new Purchase(3, amount, $"{purchaseNumber} purchase with amount: {amount}");

            employee.ProcessRequest(fourthPurchase);
            ReadLine();
        }
        private static void Main(string[] args)
        {
            IApprover director      = new Director();
            IApprover vicePresident = new VicePresident();
            IApprover president     = new President();

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

            Purchase p = new Purchase(8884, 350, "Assets");

            director.ProcessRequest(p);
            Purchase p1 = new Purchase(5675, 33390, "Project Poison");

            director.ProcessRequest(p1);
            Purchase p2 = new Purchase(5676, 144400, "Project BBD");

            director.ProcessRequest(p2);


            Console.ReadKey();
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            // Setup Chain of Responsibility
            Approver ronny = new Director();
            Approver bobby = new VicePresident();
            Approver ricky = new President();

            ronny.SetSuccessor(bobby);
            bobby.SetSuccessor(ricky);

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

            ronny.ProcessRequest(p);

            p = new Purchase(5675, 33390.10, "Project Poison");
            ronny.ProcessRequest(p);

            p = new Purchase(5676, 144400.00, "Project BBD");
            ronny.ProcessRequest(p);

            // Wait for user
            Console.ReadKey();
        }