예제 #1
0
        public static void Main(string[] args)
        {
            Console.WriteLine("========責任鏈模式-測試========");

            Manager pm = new CommonManger("PM經理");
            Manager gl = new MajorManger("總監");
            Manager gm = new GeneralManger("總經理");

            pm.setSuperior(gl);
            gl.setSuperior(gm);

            ApplyRequest request = new ApplyRequest();

            request.RequestType    = "請假";
            request.RequestContent = "小菜請假";
            request.RequestCount   = 2;
            pm.apply(request);
            request.RequestCount = 4;
            pm.apply(request);
            request.RequestCount = 12;
            pm.apply(request);

            request.RequestType    = "加薪";
            request.RequestContent = "小菜加薪";
            request.RequestCount   = 2000;
            pm.apply(request);
            request.RequestCount = 999;
            pm.apply(request);
        }
예제 #2
0
 public void Approve(ApplyRequest request)
 {
     if (request.Amount < 10000)
     {
         Console.WriteLine($"{Name}审批已完成,结束流程。");
     }
     else
     {
         Console.WriteLine($"{Name}审批已完成,等待{NextApprover.Name}审批。");
         NextApprover.Approve(request);
     }
 }
예제 #3
0
 public override void apply(ApplyRequest request)
 {
     if (request.RequestType.Equals("請假") && request.RequestCount <= 5)
     {
         Console.Write(request.RequestType + ":" + request.RequestContent);
         Console.WriteLine(" " + request.RequestCount + " 天 " + name + "批准");
     }
     else
     {
         if (superior != null)
         {
             superior.apply(request);
         }
     }
 }
예제 #4
0
 public override void apply(ApplyRequest request)
 {
     if (request.RequestType.Equals("請假"))
     {
         Console.Write(request.RequestType + ":" + request.RequestContent);
         Console.WriteLine(" " + request.RequestCount + " 天 " + name + "批准");
     }
     else
     {
         if (request.RequestType.Equals("加薪") && request.RequestCount <= 1000)
         {
             Console.Write(request.RequestType + ":" + request.RequestContent);
             Console.WriteLine(" " + request.RequestCount + " 元 " + name + "批准");
         }
         else
         {
             Console.Write(request.RequestType + ":" + request.RequestContent);
             Console.WriteLine(" " + request.RequestCount + " 元 " + name + "駁回");
         }
     }
 }
예제 #5
0
 public void Approve(ApplyRequest request)
 {
     Console.WriteLine($"{Name}已审批完成,流程结束。");
 }
예제 #6
0
 public abstract void apply(ApplyRequest request);