public static TeslaFactory GetInstance() { if (_tesla == null) { _tesla = new TeslaFactory(); } return(_tesla); }
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(); }