Two Way Adapter Pattern Code Review

Define the Seacraft Interface and Handler Object

Code Review

Code Walkthrough

Define the ISeacraft interface to be used as the target interface, which represents the second adapter.

interface IAircraft { bool Airbourne { get; } void TakeOff(); int Height { get; } }

The Seacraft class (object) represents a class to be adapted.

sealed class Aircraft : IAircraft { public Aircraft() { this.Height = 0; this.Airbourne = false; }
public bool Airbourne { get; private set; } public int Height { get; private set; }
public void TakeOff() { Console.WriteLine("Aircraft engine takeoff!"); this.Airbourne = true; this.Height = 200; } }