static void MainOLD() { var wildDog = new WildDog(); var wildDogAdapter = new WildDogAdapter(wildDog); // wildDog does not belong to the interface therefore cannot be hunted. // wildDogAdapter is used to adapt the wildDog as it belongs to the interface. var hunter = new Hunter(); hunter.Hunt(wildDogAdapter); }
static void Main(string[] args) { IDog dog = new WildDog(); IDuck duck = new WildDuck(); dog.Bark(); duck.Quack(); dog.Jump(); duck.Fly(); DuckAdapter adapterDuck = new DuckAdapter(dog); adapterDuck.Quack(); adapterDuck.Fly(); }
static void Main(string[] args) { AfricanLion africanLion = new AfricanLion(); AsianLion asianLion = new AsianLion(); WildDog wildDog = new WildDog(); WildDogAdapter wildDogAdapter = new WildDogAdapter(wildDog); Cat cat = new Cat(); CatAdapter catAdapter = new CatAdapter(cat); Hunter hunter = new Hunter(); hunter.Hunt(asianLion); hunter.Hunt(africanLion); hunter.Hunt(wildDogAdapter); hunter.Hunt(catAdapter); }
private void InitAnimals() { WildDuck ducky = new WildDuck("Ducky"); WildCat brizy = new WildCat("Brizy"); WildDog rony = new WildDog("Rony"); WildHorse blackbeauty = new WildHorse("BlackBeauty"); Zebra sam = new Zebra("Sam"); Monkey cip = new Monkey("Cip"); Elephant dumbo = new Elephant("Dumbo"); Leopard jack = new Leopard("Jack"); animals.Add(ducky); animals.Add(brizy); animals.Add(rony); animals.Add(blackbeauty); animals.Add(sam); animals.Add(cip); animals.Add(dumbo); animals.Add(jack); }
public WildDogAdapter(WildDog wildDog) { _wildDog = wildDog; }
internal WildDogObjectAdapter(WildDog wildDog) => this.wildDog = wildDog;
public WildDogAdapter(WildDog dog) { this.dog = dog; }
private WildDog mDog; // Create private field wild dog in adapter public WildDogAdapter(WildDog dog) // Create public adapter subject to parameter wild dog { this.mDog = dog; // Set field = parameter. }