Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            ICarFactory fordCar = new FordCarFactory();
            ICarFactory bmwCar  = new BMWCarFactory();

            CarWorld carWorld = new CarWorld(bmwCar); //fordCar yerine bmwCar yaz ve dene.

            carWorld.CarInfos();

            Console.Read();
        }
Ejemplo n.º 2
0
    public AbstractFactoryExample()
    {
        string     type    = "";
        CarFactory facotry = null;

        if (type == "FORD")
        {
            facotry = new FordCarFactory();
        }
        ICar MyFamilyCar = facotry.CreateFamilyCar();
        ICar MyCityCar   = facotry.CreateCityCar();
    }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            FordCarFactory fordCarFactory = new FordCarFactory();
            Driver         user1          = new Driver(fordCarFactory);

            user1.RunCars();

            MercedesCarFactory mercedesCarFactory = new MercedesCarFactory();
            Driver             user2 = new Driver(mercedesCarFactory);

            user2.RunCars();

            Console.ReadKey();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// A method to show how AbstractFactory works
        /// </summary>
        static void CreateTire(string carModel)
        {
            AbstractCarFactory carFactory = null;

            Console.WriteLine("Creating Tire");

            switch (carModel)
            {
            case "Ford":
                carFactory = new FordCarFactory();
                break;

            case "Dodge":
                carFactory = new DodgeCarFactory();
                break;

            default:
                break;
            }

            Tire tire = carFactory.CreateTire();

            Console.WriteLine($"Created Tire and the name = {tire.Name}");
        }
Ejemplo n.º 5
0
        /// <summary>
        /// A method to show how AbstractFactory works
        /// </summary>
        static void CreateHeadlight(string carModel)
        {
            AbstractCarFactory carFactory = null;

            Console.WriteLine("Creating Headlight");

            switch (carModel)
            {
            case "Ford":
                carFactory = new FordCarFactory();
                break;

            case "Dodge":
                carFactory = new DodgeCarFactory();
                break;

            default:
                break;
            }

            Headlight headlight = carFactory.CreateHeadlight();

            Console.WriteLine($"Created Headlight and the name = {headlight.Name}");
        }