public override void ProcessRequest(Purchase purchase)
 {
     if (purchase.Amount < 100000.0)
     {
         Console.WriteLine($"{this.GetType().Name} approved request #{purchase.Number}");
     }
     else
     {
         Console.WriteLine($"Request #{purchase.Number} requires an executive meeting!");
     }
 }
예제 #2
0
 public override void ProcessRequest(Purchase purchase)
 {
     if (purchase.Amount < 25000)
     {
         Console.WriteLine($"{this.GetType().Name} approved request {purchase.Number}");
     }
     else if (this.Successor != null)
     {
         this.Successor.ProcessRequest(purchase);
     }
 }
예제 #3
0
 public override void ProcessRequest(Purchase purchase)
 {
     if (purchase.Amount < 10000.0)
     {
         Console.WriteLine("{0} approved request #{1}", this.GetType().Name, purchase.Number);
     }
     else if (this.Successor != null)
     {
         this.Successor.ProcessRequest(purchase);
     }
 }
        public static void Main()
        {
            Approver teamLead = new TeamLead();
            Approver vicePresident = new VicePresident();
            Approver president = new President();

            teamLead.SetSuccessor(vicePresident);
            vicePresident.SetSuccessor(president);

            Purchase purchase = new Purchase(2019, 90000.00);
            teamLead.ProcessRequest(purchase);
        }
        internal static void Main()
        {
            Approver teamLead = new TeamLead();
            Approver vicePresident = new VicePresident();
            Approver president = new President();

            teamLead.SetSuccessor(vicePresident);
            vicePresident.SetSuccessor(president);

            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);
        }
예제 #6
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);

            // Wait for user
            Console.ReadKey();
        }
예제 #7
0
        static void Main(string[] args)
        {
            Approver larry = new MiddleManager();
            Approver bob = new VicePresident();
            Approver joe = new President();
            Approver end = new EndOfChain();

            larry.SetSuccessor(bob);
            bob.SetSuccessor(joe);
            joe.SetSuccessor(end);

            Purchase purchase1 = new Purchase { Amount = 100, Number = 1, Purpose = "R&D (Rest&Darts)" };
            Purchase purchase2 = new Purchase { Amount = 5000, Number = 2, Purpose = "Moose hunting" };
            Purchase purchase3 = new Purchase { Amount = 1000000, Number = 3, Purpose = "Bribery" };

            Console.WriteLine("Response for {0}: {1}", purchase1.ToString(), larry.ProcessRequest(purchase1));
            Console.WriteLine("Response for {0}: {1}", purchase2.ToString(), larry.ProcessRequest(purchase2));
            Console.WriteLine("Response for {0}: {1}", purchase3.ToString(), larry.ProcessRequest(purchase3));

            Console.ReadLine();
        }
예제 #8
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();
 }
예제 #9
0
 public abstract void ProcessRequest(Purchase purchase);
예제 #10
0
 public abstract void ProcessRequest(Purchase purchase);