Exemple #1
0
        public void Run()
        {
            // Setup Chain of Responsibility
            Director Larry = new Director("Larry");
            VicePresident Sam = new VicePresident("Sam");
            President Tammy = new President("Tammy");
            Larry.SetSuccessor(Sam);
            Sam.SetSuccessor(Tammy);

            // Generate and process different requests
            PurchaseRequest rs = new PurchaseRequest(2034, 350.00, "Supplies");
            Larry.ProcessRequest(rs);

            PurchaseRequest rx = new PurchaseRequest(2035, 32590.10, "Project X");
            Larry.ProcessRequest(rx);

            PurchaseRequest ry = new PurchaseRequest(2036, 122100.00, "Project Y");
            Larry.ProcessRequest(ry);
        }
Exemple #2
0
 // Methods
 public override void ProcessRequest(PurchaseRequest request)
 {
     if (request.Amount < 10000.0)
     {
         Console.WriteLine("{0} {1} approved request# {2}", this, name, request.Number);
     }
     else
     {
         if (successor != null)
         {
             successor.ProcessRequest(request);
         }
     }
 }
Exemple #3
0
 public abstract void ProcessRequest(PurchaseRequest request);
Exemple #4
0
 // Methods
 public override void ProcessRequest(PurchaseRequest request)
 {
     if (request.Amount < 100000.0)
     {
         Console.WriteLine("{0} {1} approved request# {2}", this, name, request.Number);
     }
     else
     {
         Console.WriteLine("Request# {0} requires " + "an executive meeting!", request.Number);
     }
 }