• 职责链模式c#(处理车)


    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace 职责链模式
    {
        public interface ICarHandler
        {
            ICarHandler next { get; set; }
            ICarHandler setNextCanHandler(ICarHandler handler);
            void HandlerCar();
        }

        public class ACarHander : ICarHandler
        {
          
            public ICarHandler next { get; set; }

            public ICarHandler setNextCanHandler(ICarHandler handler)
            {
                this.next = handler;
                return this.next;
            }

            public void HandlerCar()
            {
                Console.WriteLine("处理车头");
                this.next.HandlerCar();
            }
        }
        public class BCarHander : ICarHandler
        {

            public ICarHandler next { get; set; }

            public ICarHandler setNextCanHandler(ICarHandler handler)
            {
                this.next = handler;
                return this.next;
            }

            public void HandlerCar()
            {
                Console.WriteLine("处理车身");
                this.next.HandlerCar();
            }
        }
        public class CCarHander : ICarHandler
        {

            public ICarHandler next { get; set; }

            public ICarHandler setNextCanHandler(ICarHandler handler)
            {
                this.next = handler;
                return this.next;
            }

            public void HandlerCar()
            {
                Console.WriteLine("处理车尾");
                this.next.HandlerCar();
            }
        }
        class Program
        {
            static void Main(string[] args)
            {
                ICarHandler c1=new ACarHander();
                ICarHandler c2=new BCarHander();
                ICarHandler c3=new CCarHander();
                c1.setNextCanHandler(c2).setNextCanHandler(c3);
                c1.HandlerCar();
                Console.ReadKey();
            }
        }
    }

  • 相关阅读:
    基于python+django+mysql的接口测试平台
    firefox没有装在C盘,webdriver启动firefox时报错
    Python知识点面试题
    Python面试题整理
    Python程序猿面试杂谈
    Python面试-websocket及web框架
    Python面试-DB相关
    Python面试简介及并行并发
    flink-demo2
    flink-table demo
  • 原文地址:https://www.cnblogs.com/kexb/p/4525226.html
Copyright © 2020-2023  润新知