C++细节深度探索及软件工程
1namespace BridgeDesignPattern 2{ 3 abstract class TSquare 4 { 5 public abstract void OnKey(); 6 public abstract void Conflict(); 7 public abstract void Glitter(); 8 }; 910 class TSquareHole : TSquare11 {12 private TSquareImp _imp;13 public TSquareHole(TSquareImp _imp)14 {15 this._imp = _imp;16 }17 public override void OnKey()18 {19 _imp.OnKey();20 }21 public override void Conflict()22 {23 _imp.Conflict();24 }25 public override void Glitter()26 {27 _imp.Glitter();28 }29 };3031 abstract class TSquareImp32 {33 public abstract void OnKey();34 public abstract void Conflict();35 public abstract void Glitter();3637 };38 class TPCSquareHoleImp : TSquareImp39 {40 public override void OnKey()41 {42 Console.WriteLine("TPCSquareHoleImp On key");4344 }45 public override void Conflict()46 {47 Console.WriteLine("TPCSquareHoleImp Conflict");48 }49 public override void Glitter()50 {51 Console.WriteLine("TPCSquareHoleImp Glitter");52 }53 };54 class TMobileSquareHoleImp:TSquareImp55 {56 public override void OnKey()57 {58 Console.WriteLine("TMobileSquareHoleImp On key");5960 }61 public override void Conflict()62 {63 Console.WriteLine("TMobileSquareHoleImp Conflict");64 }65 public override void Glitter()66 {67 Console.WriteLine("TMobileSquareHoleImp Glitter");68 }69 };
71 }
Powered by: C++博客 Copyright © 常兴龙