Beispiel #1
0
 public static AudiFactory GetInstance()
 {
     if (_audi == null)
     {
         _audi = new AudiFactory();
     }
     return(_audi);
 }
Beispiel #2
0
        private static void Case1()
        {
            IAutoMobileFactory factory    = BMWFactory.GetInstance();
            IAutoMobile        autoMobile = factory.Make();

            autoMobile.Start();
            autoMobile.Stop();

            IAutoMobileFactory factory1    = AudiFactory.GetInstance();
            IAutoMobile        autoMobile1 = factory1.Make();

            autoMobile1.Start();
            autoMobile1.Stop();

            IAutoMobileFactory factory2    = TeslaFactory.GetInstance();
            IAutoMobile        autoMobile2 = factory2.Make();

            autoMobile2.Start();
            autoMobile2.Stop();
        }