Ejemplo n.º 1
0
 public override void Settlement(SettlementRequest settlementRequest)
 {
     if (settlementRequest._memberType == MemberType.GoldMember)
     {
         Console.WriteLine($"黄金会员,9折计算。最后金额为{settlementRequest._money*0.9M}");
     }
     else
     {
         nextHandler.Settlement(settlementRequest);
     }
 }
Ejemplo n.º 2
0
 public override void Settlement(SettlementRequest settlementRequest)
 {
     if (settlementRequest._memberType == MemberType.NoMember)
     {
         Console.WriteLine($"无会员,不进行折扣计算。最后金额为{settlementRequest._money}");
     }
     else
     {
         nextHandler.Settlement(settlementRequest);
     }
 }
Ejemplo n.º 3
0
 public override void Settlement(SettlementRequest settlementRequest)
 {
     if (settlementRequest._memberType == MemberType.DiamondsMember)
     {
         Console.WriteLine($"钻石会员,7折计算。最后金额为{settlementRequest._money*0.7M}");
     }
     else
     {
         nextHandler.Settlement(settlementRequest);
     }
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            ///设置请求
            SettlementRequest settlementRequest = new SettlementRequest(200, MemberType.GoldMember);

            ///初始化具体处理
            SettlementHandler NoMember       = new NoMemberHandler();
            SettlementHandler Member         = new MemberHandler();
            SettlementHandler GoldMember     = new GoldMemberHandler();
            SettlementHandler DiamondsMember = new DiamondsMemberHandler();

            ///设置责任链
            NoMember.nextHandler   = Member;
            Member.nextHandler     = GoldMember;
            GoldMember.nextHandler = DiamondsMember;

            ///处理请求
            NoMember.Settlement(settlementRequest);
        }
Ejemplo n.º 5
0
 public abstract void Settlement(SettlementRequest settlementRequest);