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); }
public static void Main(string[] args) { Approver ronny = new Manager(); Approver mony = new Director(); Approver poly = new President(); ronny.SetSuccessor(mony); mony.SetSuccessor(poly); var purchase = new Purchase(1, "Apple", 500); ronny.ProcessRequest(purchase); purchase = new Purchase(2, "Mango", 4500); ronny.ProcessRequest(purchase); purchase = new Purchase(3, "Gold", 9500); ronny.ProcessRequest(purchase); Console.ReadKey(); }
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(); }