// MyAdapterusing System; // Class1class SimpleDrawer {// Methods virtual public void SetColor (string name) {}}; // Adapter Class which enables class1 to use class2 methodsclass AssistantDrawer: SimpleDrawer {// use the Adaptee ProfessionalDrawer drawer = new ProfessionalDrawer (); // Methods Override public void setColor (String name) {// colors switch (name) {Case "White": Drawer.SetColor (255, 255, 255); Break; Case "Black": Drawer.SetColor (0, 0, 0); Break; default: console.writeline ("I Haven't Seen this Color!"); Break;}}}; // Class2, Adapteeclass ProfessionalDrawer {// Methods Public Void SetColor (int A, int b, int c) {Console.WriteLine ("Set The Color TO RGB ({0}, {1}, {2})", A, B, C);}};
// TestAppClass TestApp {public static void main (String [] args) {assistantdrawer Drawer = new assistantdrawer (); Drawer.SetColor ("red"); Drawer.SetColor ("Black"); Drawer.SetColor ("White) While (TRUE) {}}};