예제 #1
0
        static void Main(string[] args)
        {
            Game  game  = new Game();
            Music music = new Music();

            //实例化一个Nokia的手机
            Nokia nokia = new Nokia();

            nokia.SetUp(game);
            nokia.Run();
            nokia.SetUp(music);
            nokia.Run();

            Console.WriteLine();

            //实例化一个Samsung的手机
            Samsung samsung = new Samsung();

            samsung.SetUp(game);
            samsung.Run();
            samsung.SetUp(music);
            samsung.Run();

            Console.ReadKey();
        }
예제 #2
0
        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();
        }