Beispiel #1
0
        public static void Case2()
        {
            AutoMobileFactory autoMobileFactory = AutoMobileFactory.GetInstance();
            IAutoMobile       iautoMobile;

            iautoMobile = autoMobileFactory.Make(AutoType.AUDI);
            Display(iautoMobile);
            iautoMobile = autoMobileFactory.Make(AutoType.BMW);
            Display(iautoMobile);
            iautoMobile = autoMobileFactory.Make(AutoType.TESLA);
            Display(iautoMobile);
        }
        static void Main(string[] args)
        {
            AutoMobileFactory factory = AutoMobileFactory.GetInstance();

            IAutomobile auto = factory.Make(AutoType.AUDI);

            auto.Start();
            auto.Stop();

            Type t = auto.GetType();

            Console.WriteLine(t);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            try {
                AutoMobileFactory factory = new AutoMobileFactory();
                IAutomobile       bmw     = factory.Make(Auto.AutoType.BMW);
                bmw.Start();
                bmw.Stop();

                IAutomobile audi = factory.Make(Auto.AutoType.AUDI);
                audi.Start();
                audi.Stop();

                IAutomobile tesla = factory.Make(Auto.AutoType.TESLA);
                tesla.Start();
                tesla.Stop();

                IAutomobile hyundai = factory.Make(Auto.AutoType.UNDEFINED);
            }catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadLine();
        }