コード例 #1
0
ファイル: Program.cs プロジェクト: amala-josh/Handson
        static void Main(string[] args)
        {
            Console.WriteLine("Enter car(Audi or Mercedes): ");
            string  car     = Console.ReadLine();
            Factory factory = FactoryProducer.getFactory(car);
            ITire   tire    = factory.makeTire();

            tire.tire();
            IHeadlight headlight = factory.makeHeadlight();

            headlight.headlight();
            Console.ReadLine();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //Audi
            Factory    factory        = FactoryProducer.getFactory(true); //false for Audi
            ITire      TireOfCar      = factory.makeTire();
            IHeadlight HeadlightOfCar = factory.makeHeadlight();

            TireOfCar.tire();
            HeadlightOfCar.headlight();

            //Mercedes
            factory        = FactoryProducer.getFactory(true); //true for Mercedes
            TireOfCar      = factory.makeTire();
            HeadlightOfCar = factory.makeHeadlight();
            TireOfCar.tire();
            HeadlightOfCar.headlight();

            Console.ReadLine();
        }
コード例 #3
0
 public CarClient(Factory factory)
 {
     Headlight = factory.makeHeadlight();
     Tire      = factory.makeTire();
 }