static void Main(string[] args) { try { {//BasicStructure Abstraction abstraction = new RefinedAbstraction(); abstraction.SetImplementor(new ConcreteImplementorA()); abstraction.Operation(); } {//SituationSimulation HandsetBrand huawei = new Huawei(); huawei.SetHandsetBrand(new HandsetGame()); huawei.Run("华为"); HandsetBrand xiaomi = new Xiaomi(); xiaomi.SetHandsetBrand(new HandsetGame()); xiaomi.Run("小米"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.ReadKey(); }
static void Main(string[] args) { CellPhone phone1 = new Samsung(); CellPhone phone2 = new Huawei(); phone1.SetSoftware(new WeChat()); phone1.RunSoftware(); phone2.SetSoftware(new QQ()); phone2.RunSoftware(); Console.Read(); }