static void Main(string[] args) { //MethodChain(); 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); }
static void Main() { // 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(); }