static void Main(string[] args)
        {
            //Case1();
            AutomobileFactory factory = AutomobileFactory.GetInstance();
            IAutomobile       auto1   = factory.Make(AutoType.AUDI);

            Console.WriteLine(auto1.GetType());
            auto1.Start();

            auto1.Stop();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            //Case1();
            IAutomobile       mobile;
            AutomobileFactory factory = AutomobileFactory.GetInstance();

            mobile = factory.Make(AutoType.AUDI);
            mobile.Start();
            mobile.Stop();
            mobile = factory.Make(AutoType.BMW);
            mobile.Start();
            mobile.Stop();
        }
Esempio n. 3
0
        public void Setup()
        {
            _subareOutbackMock = new SubaruOutback();
            _suvMock           = new SUV();
            _truckMock         = new Truck();

            var autoMobiles = new IAutomobile[]
            {
                _subareOutbackMock,
                _suvMock,
                _truckMock
            };

            _automobileFactory = new AutomobileFactory(autoMobiles);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            AutomobileFactory factory = new AutomobileFactory();

            try
            {
                IAutomobile bmw = factory.make(AutoType.BMW);
                bmw.start();
                bmw.stop();
                IAutomobile audi = factory.make(AutoType.AUDI);
                audi.start();
                audi.stop();
                IAutomobile hyundai = factory.make(AutoType.UNSPECIFIED);
            }
            catch (UnspecifiedVehicleException e)
            {
                Console.WriteLine(e.Message);
            }

            Console.Read();
        }