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); }
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(); }
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(); }
public CamelToTransportAdapter(Camel camel) => _camel = camel;
public CamelToTransportAdapter(Camel c) { camel = c; }