My adapter in c #

xiaoxiao2021-03-06  227

// 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) {}}};

转载请注明原文地址:https://www.9cbs.com/read-128570.html

New Post(0)