Esempio n. 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);
        }
Esempio n. 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();
        }
Esempio n. 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();
        }
Esempio n. 4
0
 public CamelToTransportAdapter(Camel camel) => _camel = camel;
Esempio n. 5
0
 public CamelToTransportAdapter(Camel c)
 {
     camel = c;
 }