static void Main(string[] args) { RemoteControl remote = new ConcreteRemote { GetTV = new ChangHong() }; remote.On(); remote.Wacthing(); remote.Off(); remote.GetTV = new SuoNi(); remote.On(); remote.Wacthing(); remote.Off(); Console.ReadKey(); }
static void Main(string[] args) { // 创建一个遥控器 RemoteControl remoteControl = new ConcreteRemote(); // 长虹电视机 remoteControl.Implementor = new ChangHong(); remoteControl.On(); remoteControl.SetChannel(); remoteControl.Off(); Console.WriteLine(); // 三星牌电视机 remoteControl.Implementor = new Samsung(); remoteControl.On(); remoteControl.SetChannel(); remoteControl.Off(); Console.Read(); }