static void Main(string[] args) { Approver director = new Director(); Approver vp = new VicePresident(); Approver president = new President(); director.SetSuccessor(vp); vp.SetSuccessor(president); Purchase pur = new Purchase { Number = 1000, Amount = 350.00, Purpose = "assets" }; director.ProcessRequest(pur); pur = new Purchase { Number = 2000, Amount = 35000.00, Purpose = "assets2" }; director.ProcessRequest(pur); pur = new Purchase { Number = 3000, Amount = 95000.00, Purpose = "assets" }; director.ProcessRequest(pur); }
static void Main(string[] args) { Manager manager = new Manager(); VicePresident vicePresident = new VicePresident(); President president = new President(); manager.SetSuccessor(vicePresident); vicePresident.SetSuccessor(president); Expense expense = new Expense(); expense.Detail = "Training"; expense.Amount = 18; manager.HandleExpenses(expense); Console.ReadLine(); }
static void Main() { // Setup chain of responsability Approver ronny = new Director(); Approver bobby = new VicePresident(); Approver rick = new President(); ronny.SetSuccessor(bobby); bobby.SetSuccessor(rick); // Generate and process purchase requests Purchase p = new Purchase(1000, 350.00, "Assets"); ronny.ProcessRequest(p); p = new Purchase(1001, 33390.10, "Project Poison"); ronny.ProcessRequest(p); p = new Purchase(1002, 144400.00, "Project BBD"); ronny.ProcessRequest(p); // Wait for client Console.ReadKey(); }