예제 #1
0
        static void Main(string[] args)
        {
            Driver driver = new Driver();

            ITransport car = new Car();

            driver.Travel(car);

            Camel      camel   = new Camel();
            ITransport adapter = new CamelToTransportAdapter(camel);

            driver.Travel(adapter);
        }
예제 #2
0
        static void Main(string[] args)
        {
            Driver driver = new Driver();
            Auto   auto   = new Auto();

            driver.Travel(auto);

            Camel      camel          = new Camel();
            ITransport camelTransport = new CamelToTransportAdapter(camel);

            driver.Travel(camelTransport);

            Console.ReadLine();
        }
예제 #3
0
        static void Main(string[] args)
        {
            // путешественник
            Driver driver = new Driver();
            // машина
            Auto auto = new Auto();

            // отправляемся в путешествие
            driver.Travel(auto);
            // встретились пески, надо использовать верблюда
            Camel camel = new Camel();
            // используем адаптер
            ITransport camelTransport = new CamelToTransportAdapter(camel);

            // продолжаем путь по пескам пустыни
            driver.Travel(camelTransport);

            Console.Read();
        }
예제 #4
0
 public CamelToTransportAdapter(Camel camel) => _camel = camel;
예제 #5
0
 public CamelToTransportAdapter(Camel c)
 {
     camel = c;
 }