示例#1
0
 public override void ApproveRequest(Loan loanRequest)
 {
     if (loanRequest.Amount < ApproveLimit)
     {
         Console.WriteLine("Approved {0:C2} loan for {1} by the Bank {2}", loanRequest.Amount, loanRequest.Purpose, this.GetType().Name);
     }
     else if (this.Successor != null)
     {
         this.Successor.ApproveRequest(loanRequest);
     }
 }
 public override void ApproveRequest(Loan loanRequest)
 {
     if (loanRequest.Amount < ApproveLimit)
     {
         Console.WriteLine("Approved {0:C2} loan for {1} by the Bank {2}", loanRequest.Amount, loanRequest.Purpose, this.GetType().Name);
     }
     else
     {
         Console.WriteLine("Your request for {0} needs to be discussed at a board meeting", loanRequest.Purpose);
     }
 }
        public static void Main()
        {
            LoanHandler lowLevelClerk = new Clerk();
            LoanHandler midLevelManager = new AssistanManager();
            LoanHandler topExecuive = new GeneralManager();

            lowLevelClerk.SetSuccessor(midLevelManager);
            midLevelManager.SetSuccessor(topExecuive);

            var loan = new Loan("New Laptop", 1999);
            lowLevelClerk.ApproveRequest(loan);

            loan = new Loan("Fancy Sport Car", 180000);
            lowLevelClerk.ApproveRequest(loan);

            loan = new Loan("House in Miami", 1750000);
            lowLevelClerk.ApproveRequest(loan);

            loan = new Loan("Shiny Yacht", 12000000);
            lowLevelClerk.ApproveRequest(loan);
        }