static void Main(string[] args) { Approver jello = new Manager("jello"); Approver jimmy = new VicePresident("jimmy"); Approver taffy = new President("taffy"); jello.NextApprover = jimmy; jimmy.NextApprover = taffy; //买打印机 PurchaseRequest request1 = new PurchaseRequest(500, "printer"); jello.ProcessRequest(request1); //买PC PurchaseRequest request2 = new PurchaseRequest(4000, "PC"); jello.ProcessRequest(request2); //买PCs PurchaseRequest request3 = new PurchaseRequest(8000, "PCs"); jello.ProcessRequest(request3); //买工作站 PurchaseRequest request4 = new PurchaseRequest(15000, "WorkStation"); jello.ProcessRequest(request4); Console.ReadKey(); }
static void Main(string[] args) { AskLeaveRequest request1 = new AskLeaveRequest("李江", 1.0); Approver manager = new Manager("mrs陈"); Approver Hr = new HR("mr张"); manager.NextApprover = Hr; manager.ProcessRequest(request1); Console.WriteLine("Hello World!"); }
static void Main(string[] args) { PurchaseRequest requestTelphone = new PurchaseRequest(4000.0, "Telphone"); PurchaseRequest requestSoftware = new PurchaseRequest(10000.0, "Visual Studio"); PurchaseRequest requestComputers = new PurchaseRequest(40000.0, "Computers"); Approver manager = new Manager("LearningHard"); Approver Vp = new VicePresident("Tony"); Approver Pre = new President("BossTom"); // 设置责任链 manager.NextApprover = Vp; Vp.NextApprover = Pre; // 处理请求 Console.WriteLine("\n\nRequest For : Telphone"); manager.ProcessRequest(requestTelphone); Console.WriteLine("\n\nRequest For : Visual Studio"); manager.ProcessRequest(requestSoftware); Console.WriteLine("\n\nRequest For : Computers"); manager.ProcessRequest(requestComputers); Console.ReadLine(); }