コード例 #1
0
        static void Main(string[] args)
        {
            ISpeakable english = new HelloInEnglish();
            var        spanish = new HelloInSpanish();

            Hello hello = new Hello(english);//pass in instance of hello in english

            hello.Speak();



            Hello hello2 = new Hello(spanish);

            hello2.Speak();


            var hellofr = new Hello(new HelloInFrench());//did this so not create new var

            hellofr.Speak();


            (new Hello(new HelloInChinese())).Speak();
            //(new Hello(new HelloInChinese())).Goodbye();
            TestInterfaceWidgets();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            var english = new HelloInEnglish();
            var spanish = new HelloInSpanish();

            var hello = new Hello(english);

            hello.Speak();

            var hello2 = new Hello(spanish);

            hello2.Speak();

            var hellofr = new Hello(new HelloInFrench());

            hellofr.Speak();

            (new Hello(new HelloInPirate())).Speak();
        }